Attack a sacred Python Cow
Nikolaus at rath.org
Mon Jul 28 09:35:16 CEST 2008
Michael Torrie <torriem at gmail.com> writes:
> Colin J. Williams wrote:
>>> def fun( ., cat):
>> I don't see the need for the comma in fun.
> It (the entire first variable!) is needed because a method object is
> constructed from a normal function object:
> def method(self,a,b):
> class MyClass(object):
> That's precisely the same as if you'd defined method inside of the class
> to begin with. A function becomes a method when the lookup procedure in
> the instance object looks up the attribute and returns (from what I
> understand) essentially a closure that binds the instance to the first
> variable of the function. The result is known as a bound method, which
> is a callable object:
> <bound method MyClass.testmethod of <__main__.instance object at xxx>>
> How would this work if there was not first parameter at all?
> In short, unlike what most of the implicit self advocates are
> saying, it's not just a simple change to the python parser to do
> this. It would require a change in the interpreter itself and how it
> deals with classes.
Thats true. But out of curiosity: why is changing the interpreter such
a bad thing? (If we suppose for now that the change itself is a good
»It is not worth an intelligent man's time to be in the majority.
By definition, there are already enough people to do that.«
PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C
More information about the Python-list