On Mon, Dec 21, 2020 at 1:09 PM Jonathan Fine <jfine2...@gmail.com> wrote:
> Going back to that, I don't see why something like > a = Timer(time_consuming_function)() > shouldn't actually provide the semantics wanted for > @Timer > a = time_consuming_function() > that was my first thought on this thread -- but it's not so simple. decorators work on functions (and classes) because they are special statements that both create an object and bind a name, so: @a_decorator def a_function(): ... is the same as: def a_function(): ... a_function = a_decorator(a_function). So we *could* have decoration syntax work for a certain subset of statements of the form: @a_decorator a_name = <something> would mean: a_name = <something> a_name = a_decorator(a_name) but that that would only work for simple assignments and I don't think it would work for the case at hand, as <something> would get evaluated before the reassignment. So I'm not sure what it *should* mean that would be useful. -CHB My preference is for code that's easier to read rather than quicker to > type. It's said that easy reading is hard writing. > https://quoteinvestigator.com/2014/11/05/hard-writing/ > > I'm also reminded of Einstein's (or is it?) Everything Should Be Made as > Simple as Possible, But Not Simpler. > https://quoteinvestigator.com/2011/05/13/einstein-simple/ > > -- > Jonathan > -- Christopher Barker, PhD Python Language Consulting - Teaching - Scientific Software Development - Desktop GUI and Web Development - wxPython, numpy, scipy, Cython
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/DWVJNYAWNSNLGW4TCIHDKYUTJYS7MC2B/ Code of Conduct: http://python.org/psf/codeofconduct/