[Python-ideas] PEP 505 (None coalescing operators) thoughts

Carl Meyer carl at oddbird.net
Tue Sep 29 20:07:10 CEST 2015

On 09/29/2015 12:04 PM, Brian O'Neill wrote:
> A further virtue of 
>     self.vertices = vertices or []
> and the like is that they coerce falsy parameters of the wrong type to the falsy object of the correct type.
> E.g. if vertices is '' or 0, self.vertices will be set to [], whereas the ternary expression only tests 
> for not-None so self.vertices will be set to a probably crazy value.

Doesn't seem like a virtue to me, seems like it's probably hiding a bug
in the calling code, which may have other ramifications. Better to have
the "crazy value" visible and fail faster, so you can go fix that bug.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150929/5ae7ffb5/attachment.sig>

More information about the Python-ideas mailing list