Python: passing a constant as method parameter -
i want pass class name method constant.
example:
def foo(bar): # ...
eventually, want able use bar class name in method foo
is possible do?
yes, can pass class argument function. below example prove it.
class bar(): @staticmethod # created staticmethod; can call without creating object def my_print(): print 'hello, class function' def foo(my_class): my_class().my_print() # call my_print() of object passed foo(bar) # pass class "bar" argument "foo()" # prints: hello, class function
Comments
Post a Comment