On Fri, 11 Mar 2005 14:04:26 -0800, jfj <[EMAIL PROTECTED]> wrote:
>Hi.
>
>Suppose this:
>
>
>
>def foo (x):
> print x
>
>f = classmethod (foo)
>
>class A: pass
>
>a=A()
>a.f = f
>
>a.f()
># TypeError: 'classmethod' object is not callable!
>
>###
>
>
jfj schreef:
Ruud wrote:
So far for *how* it works. As to *why* it works like this, I don't know
for sure. But my guess is that the reasoning was something as follows:
if you define a function (regular or something special like a
classmethod) only for an instance of a class, you obviously don't
wan
Ruud wrote:
So far for *how* it works. As to *why* it works like this, I don't know
for sure. But my guess is that the reasoning was something as follows:
if you define a function (regular or something special like a
classmethod) only for an instance of a class, you obviously don't
want to use it i
jfj wrote:
Diez B. Roggisch wrote:
Moreover the documentation sais that if the first argument is an
instance, its class will be
used for the classmethod. OTOH, "class scope" is not a real thing in
python. It is just some code which is executed and then we get its
locals and use it on Class(local
jfj schreef:
Diez B. Roggisch wrote:
I understand that this is a very peculiar use of
classmethods but is this error intentional?
Or did I completely missed the point somewhere?
Note that this is not really related to classmethods. A similar
"problem" exists if you want to use an ordinary function
Diez B. Roggisch wrote:
Moreover the documentation
sais that if the first argument is an instance, its class will be
used for the classmethod. OTOH, "class scope" is not a real thing in
python. It is just some code which is executed and then we get its
locals and use it on Class(localsDict, Base
> Not necessarily:
>
> def foo(cls):
> print cls
> f=classmethod(foo)
>
> class A: pass
>
> A.f = f
> a=A()
> a.f()
Ahhh, yes, I see the minor difference - I didn't recognize it before.
>
> This works. Anyway, the confusion starts from the documentation of
> classmethod(). Since classm
Diez B. Roggisch wrote:
I understand that this is a very peculiar use of
classmethods but is this error intentional?
Or did I completely missed the point somewhere?
A little bit: classmethods are defined in a class context.
def foo(cls):
print cls
class A:
foo = classmethod(foo)
The error
> I understand that this is a very peculiar use of
> classmethods but is this error intentional?
> Or did I completely missed the point somewhere?
A little bit: classmethods are defined in a class context.
def foo(cls):
print cls
class A:
foo = classmethod(foo)
The error you observe se
Hi.
Suppose this:
def foo (x):
print x
f = classmethod (foo)
class A: pass
a=A()
a.f = f
a.f()
# TypeError: 'classmethod' object is not callable!
###
I understand that this is a very peculiar use of
classmethods but is this error intentional?
Or did
10 matches
Mail list logo