kuroko/test/testClassMethodAssignment.krk

33 lines
510 B
Python
Raw Permalink Normal View History

class Foo:
def bar(self):
print("Called bar")
let f = Foo()
f.bar()
def other(instance):
print("Called other")
def noargs():
print("Uh oh, binding will work but call will fail.")
Foo.other = other
Foo.noargs = noargs
2022-08-06 06:20:04 +03:00
print('<bound method \'other' in str(f.other))
f.other()
2022-08-06 06:20:04 +03:00
print('<bound method \'noargs' in str(f.noargs))
try:
f.noargs()
except Exception as e:
print(e)
class SomethingCallable():
def __call__(self):
print("I can be called")
Foo.callable = SomethingCallable()
f.callable()