python: how to refer to the class from within it ( like the recursive function)

后端 未结 13 1769
旧时难觅i
旧时难觅i 2020-12-10 10:10

For a recursive function we can do:

def f(i):
  if i<0: return
  print i
  f(i-1)

f(10)

However is there a way to do the following thin

相关标签:
13条回答
  • 2020-12-10 11:05

    What do you want to achieve? It's possible to access a class to tweak its definition using a metaclass, but it's not recommended.

    Your code sample can be written simply as:

    class A(object):
        pass
    some_func(A)
    
    0 讨论(0)
提交回复
热议问题