-1
我有两个文件,main.py
和ColorPoint.py
。最后一个由Point
类和ColorPoint
类组成,继承自Point
类。有没有办法从main.py
文件中访问Point
的方法?在Python中访问父级方法
例如我有两种方法__str__
在Point
和ColorPoint
类。但我想打印colorpoint
对象只是Point
:
print colorpoint # gives output from Point class, not ColorPoint class
我知道如何从类通过super
访问父方法,但如何从main
这样做,不来上课?
这是一个不寻常的请求 - 您能不能给一些更多的信息n对你想要达到的目标,也许有更好的方法去尝试...... – 2014-11-24 13:54:59
'Point .__ str __(colorpoint)'? – Rusty 2014-11-24 13:55:21
生锈,是的 - 正是我想要的! – ovod 2014-11-24 13:57:34