Re: [Python-ideas] Attribute-Getter Syntax Proposal

2019-03-08 Thread Benedikt Werner
I just realized it doesn't work properly if the method takes some arguments, so you would actually have to use two different magic objects or something like that, but I guess the point is clear. Am 08.03.2019 um 23:08 schrieb Benedikt Werner: This was actually quite interesting to code, thanks

Re: [Python-ideas] Attribute-Getter Syntax Proposal

2019-03-08 Thread Benedikt Werner
This was actually quite interesting to code, thanks for the idea Jonathan! You can even support "magic.upper()" and "magic.real" at the same time as well as "magic[0]": class MagicClass:     NO_ARG = object()     @staticmethod     def __getattribute__(attr):     def

Re: [Python-ideas] Return for assignment blocks

2018-10-24 Thread Benedikt Werner
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: def my_func():     return def():     print("abc") to be the same as this: def my_func():     def

Re: [Python-ideas] Revisiting dedicated overloadable boolean operators

2018-08-03 Thread Benedikt Werner
The proposal is for new operators.  The operators would be "bNOT", "bAND", "bOR", and "bXOR".  They would be completely independent of the existing "not", "and", and "or" operators, operating purely on boolean values.  It would be possible to overload these operators. I see, I misunderstood

Re: [Python-ideas] With expressions

2018-08-03 Thread Benedikt Werner
For instance, what would the following do? initial = person.name [0] with suppress(AttributeError)  # Hangover from PEP 505 discussion... As the with-expression mimics the with-statement I would say this is similar to: with supress(AttributeError): tmp =

Re: [Python-ideas] Revisiting dedicated overloadable boolean operators

2018-08-03 Thread Benedikt Werner
There was a proposal to allow overloading boolean operators in Pep-335 [2], but that PEP was rejected for a variety of very good reasons.  I think none of those reasons (besides the conversation fizzling out) apply to my proposal. Maybe I am missing something, but I don't really see how this