[Python-ideas] Possibility to decorate single code line or code block?

2020-12-18 Thread Marco Sulla
Maybe it's a crazy idea, but what if we could decorate a single line of code? For example: @Timer a = time_consuming_function() This will be equivalent to using Steven's context manager, but the decorator is more simple to comment and uncomment. Maybe it could be possible to comment also code bl

[Python-ideas] Re: dataclass allow_missing option

2020-12-18 Thread Steven D'Aprano
On Thu, Dec 17, 2020 at 12:26:21PM -0500, Ricky Teachey wrote: > I really like this idea! > > I have very often had to create my own MISSING global in modules where None > might actually be a legitimate value for the dataclass member. I'm sorry Ricky, perhaps I'm missing something here, but I can

[Python-ideas] Possibility to decorate single code line or code block?

2020-12-18 Thread Stephen J. Turnbull
Marco Sulla writes: > Maybe it's a crazy idea, but what if we could decorate a single line > of code? > For example: > > @Timer > a = time_consuming_function() As syntax, I don't see the advantage over with ContextManagingTimer(): a = time_consuming_function() I don't underst