Iterators & generators (RE: Real Problems with Python)

Darrell news at dorb.com
Wed Feb 16 04:43:12 CET 2000


Guess I need to read more doc strings.

http://www.python.org/doc/current/lib/built-in-funcs.html#l2h-115
getattr (object, name)
The arguments are an object and a string. The string must be the name of one
of the object's attributes. The result is the value of that attribute. For
example, getattr(x, 'foobar') is equivalent to x.foobar.

>
> 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>

--Darrell






More information about the Python-list mailing list