[Python-ideas] Return for assignment blocks
1benediktwerner at gmail.com
Wed Oct 24 09:51:09 EDT 2018
Would you mind providing a bit more details about your proposal?
What exactly are those "Assignment Blocks" supposed to do?
If I understand your proposal correctly you want this:
to be the same as this:
But this is only my assumption as your proposal doesn't give very much
Maybe you should provide a few simple examples and explain what they are
supposed to do or what they should be equivalent to.
Your example is quite complex and to me it's not clear at all what it is
supposed to mean.
Also and probably most importantly what is the reason you want this? Are
there any good usecases where this would help?
If my assumption above is correct this just looks like a bit of
syntactic sugar that IMO isn't really neccessary. It doesn't really
improve readability or save many characters. The existing way to do this
is totally fine.
Am 24.10.2018 um 15:18 schrieb Calvin Spealman:
> I'd like to suggest what I think would be a simple addition to `def`
> and `class` blocks. I don't know if calling those "Assignment Blocks"
> is accurate, but I just mean to refer to block syntaxes that assign to
> a name. Anyway, I propose a combined return-def structure, and
> optionally also allowing a return-class version. Omitting the name
> would be allowable, as well.
> This would only apply to a `def` or `class` statement made as the last
> part of the function body, of course.
> def ignore_exc(exc_type):
> return def (func):
> return def (*args, **kwargs):
> return func(*args, **kwargs)
> except exc_type:
> Thanks for considering and for any comments, thoughts, or feedback on
> the idea!
> Python-ideas mailing list
> Python-ideas at python.org
> Code of Conduct: http://python.org/psf/codeofconduct/
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas