Preferences

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)


As 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.
you 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.

Would this statement decorator then manipulate the AST of the following statement or how would that work?
For what it's worth, you can already do: x = retry(3)(failure_prone_call)(y)
And, for that matter, expensive_module = lazy(importlib.import_module)('expensive_module') .
good luck with that syntax - it would be as possible as passing an inline-defined def as parameter instead of a lambda

This item has no comments currently.

Keyboard Shortcuts

Story Lists

j
Next story
k
Previous story
Shift+j
Last story
Shift+k
First story
o Enter
Go to story URL
c
Go to comments
u
Go to author

Navigation

Shift+t
Go to top stories
Shift+n
Go to new stories
Shift+b
Go to best stories
Shift+a
Go to Ask HN
Shift+s
Go to Show HN

Miscellaneous

?
Show this modal