我的代码需要有一个内部类,我想创建这个内部类的实例而不创建外部类的实例。
如何在python中这样做?在java中,我们可以将内部类定义为静态的,但我不知道如何在python中使内部类成为静态的。我知道对于方法我们可以使用@staticmethod
装饰器。
class Outer:
def __init__(self):
print 'Instance of outer class is created'
class Inner:
def __init__(self):
print 'Instance of Inner class is created'