我有嵌套类,因为它们紧密相关。python如何让内部类成为外部类的类型
现在我想有以下类型的代码
class one(Some-other-type):
...
// More functions here
class two(one):
// Some more functions here.
内部类“二”的类型应该是“一”,但如果我把我得到一个错误。 另一种方法是不让它嵌套像下面
class one(Some-other-type):
...
// More functions here
class two(one):
// Some more functions here.
但后来我不想当模块导入的类“两”来访问。 我并不真正关心“one”提供的功能,但为了清晰的代码,它需要在它之下。
有什么想法?
[python中从内部类访问外部类(的可能的复制http://stackoverflow.com/questions/2024566/access-outer-class- python) –
“但是当我导入模块时,我不想让类”two“可以访问。” Python不会打扰像'private'这样的访问修饰符。只需在'class _two'前加上一个下划线来表示它是私人的。因为在另一种情况下,总是可以通过one.two来访问。 – Evert
@Evert是啊我猜这就是要走的路 – Anup