A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2001-April/097614.html below:

Strange error with unbound method

Strange error with unbound method Strange error with unbound methodRobin Thomas robin.thomas at starmedia.net
Mon Apr 16 13:20:57 EDT 2001
At 04:32 PM 4/16/01 +0000, Remco Gerlich wrote:
>Fernando Rodríguez <spamers at must.die> wrote in comp.lang.python:
> >       I have a class called ParaStyle (see code below). This class has a
> > method called makeBlackAndWhite that returns a new instance of class
> > ParaStyle.
>
>In the first case you call a method on a class. That's not possible.
>
>The second case, since the list contains *instances*, everything is ok. You
>call the method on the instance.

What are you talking about? Calling unbound methods with instance as first 
argument is not just legal, it's moral!

class Foo:
     def method(self): return self

f = Foo()
Foo.method(f)
# succeeds

l = []
for i in range(100): l.append(Foo())

map(Foo.method, l)
# also succeeds, with flying colors

I asked Fernando (privately) whether his BaseObject base class was doing 
metaclass weirdness. It's either metaclass weirdness, or that paraStyles 
actually contains a non-instance-of-ParaStyle, that could cause his problem.




--
Robin Thomas
Engineering
StarMedia Network, Inc.
robin.thomas at starmedia.net



More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4