PetterS / quickjs

Thin Python wrapper of https://bellard.org/quickjs/
https://github.com/bellard/QuickJS
MIT License
181 stars 19 forks source link

need api to list all global variables #34

Closed yiwiz-sai closed 4 years ago

yiwiz-sai commented 4 years ago

is it possible to provide one?

PetterS commented 4 years ago

Isn't this just Object.keys(globalThis)?

yiwiz-sai commented 4 years ago

For example context = quickjs.Context() code = "random_name='1234567'" try: context.eval(code) except: print(traceback.format_exc())

So how do I know there is a global variable "random_name" ?

PetterS commented 4 years ago

context.eval("globalThis.random_name !== undefined")

Also, Object.keys(globalThis) will be equal to ["random_name"]

yiwiz-sai commented 4 years ago

cool, thank you very much, if test_quickjs,py has this code, it will help.