Question about map() and class methods
malraux at my-deja.com
malraux at my-deja.com
Mon Dec 20 10:04:35 EST 1999
Hi all,
I was attempting to use a class method with map() the other day, and
failed miserably.
Basically, if I have a class foo:
class foo:
def bar(self):
return(whatever)
and I try to do this:
x = map(foo.bar, someListOfFoos)
The interpreter complains that foo.bar requires a class as its
argument. Obviously, if it would only continue with the call, it would
discover that yes, indeed, it has a whole list of them to chew on.
I got around the problem by doing this:
def mapFooBar(self):
foo.bar(self)
map(mapFooBar, someListOfFoos)
Which of course works fine.
What am I missing here?
Thanks,
-scott
Sent via Deja.com http://www.deja.com/
Before you buy.
More information about the Python-list
mailing list