3 ms·
This is needed, but I don't like new keywords. What I would love, for many reasons, is if we could decorate statements. Then things like: import expensive_modu
by jmward01 1y ago
This is needed, but I don't like new keywords. What I would love, for many reasons, is if we could decorate statements. Then things like:
import expensive_module
could be:
@lazy
import expensive_module
or you could do:
@retry(3)
x = failure_prone_call(y)
lazy is needed, but maybe there is a more basic change that could give more power with more organic syntax, and not create a new keyword that is special purpose (and extending an already special purpose keyword)
- jmward01 1y agoAs a side note, It would be great to have a 'preview' for HN comments. I updated the above because I forgot to add line breaks. Sigh. I bet 'preview' would stop a lot of not well thought out comments too.
- dijksterhuis 1y agoyou can set “delay” in your profile to delay the live posting of a comment after you click the button. gives me ten minutes to edit (rewrite if i’m honest) before other people see it.
- progval 1y agoFor what it's worth, you can already do: x = retry(3)(failure_prone_call)(y)
- zahlman 1y agoAnd, for that matter, expensive_module = lazy(importlib.import_module)('expensive_module') .
- lyu07282 1y agoWould this statement decorator then manipulate the AST of the following statement or how would that work?
- _ZeD_ 1y agogood luck with that syntax - it would be as possible as passing an inline-defined def as parameter instead of a lambda