Pythonのバージョンをとして、ネストされた/インナークラスを使用するにはPythonのimportクラスが別のクラスに
class Backup:
class Create:
@staticmethod
def all():
print('create all')
@staticmethod
def user(username):
print('create user: ' + username)
@staticmethod
def file(filename):
print('create file: ' + filename)
class Restore:
@staticmethod
def all():
print('restore all')
@staticmethod
def user(username):
print('restore user: ' + username)
@staticmethod
def file(filename):
print('restore file: ' + filename)
class Delete:
@staticmethod
def all():
print('delete all')
@staticmethod
def user(username):
print('delete user: ' + username)
@staticmethod
def file(filename):
print('delete file: ' + filename)
をしかし、私は自分のモジュールにネストされたクラスを移動したいですそれらをインポートするが、私はそれを行う方法がわからない。ここでいくつかの同様のスタックオーバーフローの質問に基づいて私の最新の試みだった。もちろん、それは動作しませんでした:
from Models.Create import Create
class Backup(Create):
誰もが、私はそう、私はまだこのようなクラスのメソッドを呼び出すことができませんしようとしているものを達成する方法を知っています:Backup.Create.all()
チェック 'スーパー()'関数:https://stackoverflow.com/questions/576169/understanding-python-super-with-init-methods –
出演にもかかわらず、私は彼がに探しているとは思いませんあらゆる機能を拡張する。彼はそれらを巣に入れようとしている。 –