KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
In the following code class B has inherited yay attribute from class A , I expected this. I'd also expect that inner class B.Foo behaves the same way but it doesn't. How to make B.Foo to inherit alice attribute from class A ? I need that the inner subclass Foo in B has both the attributes alice and bob . Thanks. >>> class A: ... yay = True ... class Foo: ... alice = True ... >>> class B(A): ... nay = False ... class Foo: ... bob = False >>> B.yay True >>> B.Foo.alice Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: class Foo has no attribute 'alice'
Tags (comma-separated)
Save Edits
Cancel