Closed Konubinix closed 4 years ago
I think what is going on here, is that hammertime
is an Object
, with functions added to it. But when PScript encounters an Object
, it considers it a dict
, and the code you see there is the implementation of Python dict.get()
. So it's an unfortunate name clash.
So you'd have to trick PScript not to do this overloading. E.g.:
hammertime.gat = hammertime.get
hammertime.gat("pinch").set({"enable": True})
# or
hget = hammertime.get
hget("pinch").set({"enable": True})
Thank you for the hint :-).
I was trying to play with the Hammer javascript library. To enable pinch, the javascript document says to run
hammertime.get("pinch").set({enable: true});
. I then wrote the python equivalenthammertime.get("pinch").set({"enable": True})
and got the errorflexx-core.js:3266 Uncaught TypeError: Cannot read property 'set' of null
.This makes sense as the get method get transpiled into
I worked around this issue by calling the javascript code inside RawJS, but I wonder if there was a more elegant way of doing it.
Can we imagine adding a condition like
if(this.get != undefined) {return this.get(key);}
in the get method, and more generally in all the overrloaded methods I guess? Does it make any sense?