On 2/13/07, Josiah Carlson <[EMAIL PROTECTED]> wrote: > As for people who say, "but getattr, setattr, and delattr aren't used"; > please do some searches of the Python standard library. In a recent > source checkout of the trunk Lib, there are 100+ uses of setattr, 400+ > uses of getattr (perhaps 10-20% of which being the 3 argument form), and > a trivial number of delattr calls. In terms of applications where > dynamic attribute access tends to happen; see httplib, urllib, smtpd, > the SocketServer variants, etc.
Another data point: on our six-figure loc code base, we have 123 instances of getattr, 30 instances of setattr, and 0 instances of delattr. There are 5 instances of setattr( ... getattr( ... ) ) on one line (and probably a few more that grep didn't pick up that span multiple lines). As a comparison, enumerate (that I would have believed was much more frequent a priori), is used 67 times, and zip/izip 165 times. +1 on .[] notation and the idea in general. -Mike _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com