[Python-Dev] Re: PEP 505 (None-aware operators) for Python 3.11

2022-09-15 Thread Maarten Nieber
Hi, I wanted to propose replacing ? with -> in the none aware syntax. This 
makes the expression look like a chain, and I think that most people 
intuitively can understand how the chain might get broken (and what would 
happen in that case). For example:

zipcode = person->.address->['zipcode']

I've proposed this alternative syntax on Doug's github project, and I think he 
didn't like it so much (or at least, his co-contributor didn't like it), but I 
still wanted to propose it here as well, because I do think it's a good 
solution to the complaints that the ? operator looks cryptic. 

Best regards,
Maarten
___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/UNK66ZORXDNX22IDDFWJHDHVZGPBQETT/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: PEP 505 (None-aware operators) for Python 3.11

2022-09-15 Thread Piotr Waszkiewicz
Hi Maarten,
I like the suggestion but I'm not sure if the real problem with the PEP505
is the symbol/operator used.
Reading through the whole discussion I'm under the impression that the idea
of the None value being treated as an indicator of the missing attribute is
what prevents this PEP from happening.

Apart from that I'm all for it, (probably) regardless of the syntax (as
long as it remains short).

Best regards,
Piotr

On Thu, Sep 15, 2022 at 5:07 PM Maarten Nieber  wrote:

> Hi, I wanted to propose replacing ? with -> in the none aware syntax. This
> makes the expression look like a chain, and I think that most people
> intuitively can understand how the chain might get broken (and what would
> happen in that case). For example:
>
> zipcode = person->.address->['zipcode']
>
> I've proposed this alternative syntax on Doug's github project, and I
> think he didn't like it so much (or at least, his co-contributor didn't
> like it), but I still wanted to propose it here as well, because I do think
> it's a good solution to the complaints that the ? operator looks cryptic.
>
> Best regards,
> Maarten
> ___
> Python-Dev mailing list -- [email protected]
> To unsubscribe send an email to [email protected]
> https://mail.python.org/mailman3/lists/python-dev.python.org/
> Message archived at
> https://mail.python.org/archives/list/[email protected]/message/UNK66ZORXDNX22IDDFWJHDHVZGPBQETT/
> Code of Conduct: http://python.org/psf/codeofconduct/
>
___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/5E732BVBR3CSZEDKXREVQULDBH2GUZHN/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: PEP 505 (None-aware operators) for Python 3.11

2022-09-15 Thread Maarten Nieber
Hi Piotr, 

doesn't Doug's reply of 8:03 address this point? As he says, the none-aware 
operator never gives you None when you ask for a missing attribute (these cases 
always raise an exception). If we look at these two alternatives

phone1 = book.publisher?.owner.phone
phone2 = book.publisher.owner.phone if book.publisher else None

then they behave exactly the same. If we would misspell "owner" then in both 
versions we'd get the same AttributeError under the same conditions.

Best,
Maarten
___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/KSKTJRNSQSBRYZRY6QQY7B3TZ5J4P2PD/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: PEP 505 (None-aware operators) for Python 3.11

2022-09-15 Thread Piotr Waszkiewicz
Hi Maarten,
I'm sorry for the confusion - it was bad wording on my part.
What I really meant was that the problem with the None-aware operator, and
the reason why PEP505 has not been accepted for such a long time, is that
there's no consensus regarding the need for it (and not necessarily the
problem with the operator used to represent it - although this topic has
also been raised).

Take a look at the response by Steve Dower:
https://mail.python.org/archives/list/[email protected]/message/BRTRKGY6RLTHZJQ2US4LO7DYLSGXQ5GM/

Best regards,
Piotr

On Thu, Sep 15, 2022 at 6:54 PM Maarten Nieber  wrote:

> Hi Piotr,
>
> doesn't Doug's reply of 8:03 address this point? As he says, the
> none-aware operator never gives you None when you ask for a missing
> attribute (these cases always raise an exception). If we look at these two
> alternatives
>
> phone1 = book.publisher?.owner.phone
> phone2 = book.publisher.owner.phone if book.publisher else None
>
> then they behave exactly the same. If we would misspell "owner" then in
> both versions we'd get the same AttributeError under the same conditions.
>
> Best,
> Maarten
> ___
> Python-Dev mailing list -- [email protected]
> To unsubscribe send an email to [email protected]
> https://mail.python.org/mailman3/lists/python-dev.python.org/
> Message archived at
> https://mail.python.org/archives/list/[email protected]/message/KSKTJRNSQSBRYZRY6QQY7B3TZ5J4P2PD/
> Code of Conduct: http://python.org/psf/codeofconduct/
>
___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/CNXITRMQL2ABVLTLH2RUB53IL3F37ZH6/
Code of Conduct: http://python.org/psf/codeofconduct/