Dynamic call of a method : error
Michal Wallace
sabren at manifestation.com
Wed Jul 4 19:48:34 EDT 2001
On Wed, 4 Jul 2001, Dublanc, David wrote:
> Hello, when I execute the module :
> ***************
> L = []
>
> for method in dir(L):
> "dynamic call"
> print L.method.__doc__
This is looking for L.method, not L.append, L.count, etc.. you want
to use getattr first.
>>> L = []
>>> for method in dir(L):
... print getattr(L, method).__doc__
...
L.append(object) -- append object to end
L.count(value) -> integer -- return number of occurrences of value
L.extend(list) -- extend list by appending list elements
#(and so on)
Cheers,
- Michal
------------------------------------------------------------------------
www.manifestation.com www.sabren.net www.linkwatcher.com www.zike.net
------------------------------------------------------------------------
More information about the Python-list
mailing list