On Tue, 13 Feb 2007 11:27:48 -0800, Mike Klaas <[EMAIL PROTECTED]> wrote: >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).
Another data point: in our six-figure loc code base, we have 469 instances of getattr, 91 instances of setattr, and 0 instances of delattr. There is one instances of setattr(..., getattr(...)), and one instance of setattr(getattr(...), ...). > >+1 on .[] notation and the idea in general. > -1 on a syntax change for this. Somewhere between -0 and +0 for a builtin or library function like attrview(). Jean-Paul _______________________________________________ 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