how to make this work?

i there a way in latest built to make this old way to work ?


 
print ('Old Classmethod')   
print ()
 
class C1:
    def foo(cls, y):
        print ("classmethod", cls, y)
    foo = @classmethod(foo)
 
print (' a=',a=c1)
 
 
 

i know it can be done another way but this should stil work ok even if it is old method!

Thanks for any help

I’ve got no idea what you’re trying to do exactly - maybe use decorators/ figure out what they are :smiley: ?

print ('Old Classmethod')   
print ()
    
class C1:
    @classmethod
    def foo(cls, y):
        print ("classmethod", cls, y)
foo =""    
foo = classmethod(foo)
    
print (foo,C1)

this compiles but i’m not sure it’s what you want.

well this was the old way of dong things before decorator

and it’s one example of how it was done before
and should be working but seems it’s not
not certain if it is because of latest changes in python may be!

i’d like to have this ild way of doing thing just as an example
if i cannot add it then i won’t put this as an example because it’s not working

just ind other ways with @classmethod or @staticmethod maybe

by the way what would be this cls thing is this a command to clear ?

did a test and printed the foo and c1 values and got theses values

Old Classmethod
foo = <classmethod object at 0x09D0F9F0> c1 = <class ‘main.C1’>

is this normal ?

Thanks

Its obviously old version but it was so good to see this.I think this are one example about what they did before an it so good to remember.

do you know how to make it work cause the first example given is not working in 2,5 !

but it was working a few years back !

would be nice to show it and working

salutations

The first example can not work because there are 2 typos in it.
Well the first one might not be a typo because you probably didn’t understand that @ should only be used in an decorator expression. The second error is in the last argument to print(). a=c1 which makes it, to python, look like you want to pass an undefined variable c1 to a key word argument a, which does not exist.
You should at least read the very usefull tracebacks python gives you.

i took this example from another site and modified the names
see first example at top

but i’ll recheck and see error on console

Thanks