Iterators & generators (RE: Real Problems with Python)

Fredrik Lundh effbot at telia.com
Tue Feb 15 18:49:42 EST 2000


Darrell <darrell at dorb.com> wrote:
> > I agree, but it's gotten "better" this way, mostly via little things
like
> > the addition of dict.get() and 3-argument getattr -- not everything is
> > better spelled on 4 lines <wink>.
>
> Is there a 3-argument getattr in the CVS version ?

yes, unless someone has made a mistake
and removed it:

> python
Python 1.5.2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> print getattr.__doc__
getattr(object, name[, default]) -> value

Get a named attribute from an object; getattr(x, 'y') is equivalent to x.y.
When a default argument is given, it is returned when the attribute doesn't
exist; without it, an exception is raised in that case.

</F>





More information about the Python-list mailing list