7
class Foo():
def __init__(self):
pass
def create_another(self):
return Foo()
# is not working as intended, because it will make y below becomes Foo
class Bar(Foo):
pass
x = Bar()
y = x.create_another()
yはFooのクラスではありません。独自のインスタンスのPythonコールコンストラクタ
何かがありますか?self.constructor()
代わりに使用しますか?新しいスタイルのクラスでは
@Billiska:あなたはそうする正当な理由がない限り私は新しいスタイルのクラスを使用したいと思います。 'Foo'を' object'から継承させます。 –