A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2007-February/071077.html below:

[Python-Dev] New syntax for 'dynamic' attribute access

[Python-Dev] New syntax for 'dynamic' attribute access [Python-Dev] New syntax for 'dynamic' attribute accessGreg Ewing greg.ewing at canterbury.ac.nz
Wed Feb 14 01:24:30 CET 2007
Martin v. Löwis wrote:
> Apparently, people favor hasattr over catching 
> AttributeError. I'm not sure why this is - I would probably
> rewrite them all to deal with AttributeError if I use the new
> syntax in the first place.

Actually, I prefer using getattr with a default value over
either of those, wherever possible. AttributeError can be
raised by too many things for me to feel comfortable about
catching it.

This suggests that any proposed getattr syntax should
include a way of specifying a default value.

I'm still -1 on the basic idea, though, on the grounds of
YAGNIOE (You Aren't Going to Need It Often Enough).

--
Greg
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4