相关疑难解决方法(0)

__getattr__与__getattribute__之间的区别

我想知道何时使用__getattr____getattribute__.该文件提到了__getattribute__适用于新样式类.什么是新式课程?

python getattr getattribute

378
推荐指数
8
解决办法
12万
查看次数

从python中的内部类访问外部类

我有这样的情况......

class Outer(object):

    def some_method(self):
        # do something

    class Inner(object):
        def __init__(self):
            self.Outer.some_method()    # <-- this is the line in question
Run Code Online (Sandbox Code Playgroud)

如何OuterInner类中访问类的方法?

编辑 - 感谢您的回复.我的结论是,我需要重新评估我是如何设计这个实现的,并提出一个更强大的方法.

python scope nested inner-classes

86
推荐指数
5
解决办法
6万
查看次数

标签 统计

python ×2

getattr ×1

getattribute ×1

inner-classes ×1

nested ×1

scope ×1