Tres Seaver <tsea...@palladion.com> writes: > On 03/12/2014 04:49 PM, Chris Angelico wrote: >> You can use hasattr() in place of AttributeError > > I use: > > getattr(subject, attrname, default)? > > *all the time*.
In my opinion that's almost as ugly, because it still forces you to specify the attribute name as a string rather than an identifier. Best, Nikolaus -- Encrypted emails preferred. PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C »Time flies like an arrow, fruit flies like a Banana.« _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com