[Python-ideas] except expression

Ian Foote ian at feete.org
Thu Feb 20 23:58:39 CET 2014


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 20/02/14 17:41, Phil Connell wrote:
<snip>
> 
> 
> I'm was a fan of the colon version, but it's *really* ugly in this
> case:
> 
> elif not might_be_none.foo except AttributeError: None: ...
> 
> ': None:' is just awful.
> 

I'd spell that

    elif not (might_be_none.foo except AttributeError: None):
        ...

which is a little less ugly.

> 
> In this case, -> looks much better IMO:
> 
> elif not might_be_none.foo except AttributeError -> None: ...
> 

I'd also spell this version with parentheses.

I agree this is still an advantage for `->` over `:`, but I don't
think it is as big an advantage as it appeared at first glance.

Regards,
Ian F
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.14 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJTBoifAAoJEODsV4MF7PWzyqMH/251JN7U0WANH6jw4j4SK7IE
w/PhiZGk7FfKYXuXMuPHj9c9cSRvCD/117yz2NXBSYeskiwcB+BWMAr3nQ6GtN/T
wpYNXUfA38+Zg/n6UyP5dmCsW9JCq2gMh/gunlxfFseRgvhJQJCti8Le6pwRJFwc
x+tgFtjpKWVOo70X2Aug3P0Cl/RrKmN0XNY6uFXbd9Dsw3WL0M/7M6MU5DwH2+mf
gXTCBIm5/NaK7LVx2EdiJtmva+EG2TDVfQ6OI14sUB/iIh6ie+TzAyzbRh36m/rk
1dQDP88EjTaSWoG7GeeQYtrx/ycEv5z7guSmU5fMCaAPQPcD0abaojrts1xREls=
=lgjS
-----END PGP SIGNATURE-----


More information about the Python-ideas mailing list