pyscript icon indicating copy to clipboard operation
pyscript copied to clipboard

not implemented ast ast_generatorexp

Open jkaberg opened this issue 1 year ago • 1 comments

I'm guessing someone hasn't come around to it, just parking this here for myself or if someone else has the time 😄

majo-hast-1  | 2024-01-05 15:23:09.477 ERROR (MainThread) [custom_components.pyscript.scripts.energy_price.fetch_prices] Exception in <scripts.energy_price.fetch_prices> line 49:
majo-hast-1  |             hour['is_avarage'] = not any(value for key, value in hour.items() if key.endswith(('lowest', 'highest')))
majo-hast-1  |                                         ^
majo-hast-1  | NotImplementedError: scripts.energy_price.fetch_prices: not implemented ast ast_generatorexp

jkaberg avatar Jan 05 '24 14:01 jkaberg

Since pyscript is implemented as an interpreter, generator expressions and yield are quite hard to implement. It's mentioned in the Language Limitations section of the docs.

A workaround is to put the generator or yield code in a function with a @pyscript_compile decorator. That will use native Python.

That said, any implementations would be most welcome!

craigbarratt avatar Jan 05 '24 17:01 craigbarratt