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

Popular posts from this blog

qt - QML MouseArea onWheel event not working properly when inside QML Scrollview -

java - is not an enclosing class / new Intent Cannot Resolve Constructor -

python - Error importing VideoFileClip from moviepy : AttributeError: 'PermissionError' object has no attribute 'message' -