Question #298

What is the output of the code snippet below?
class A(object):
    x = 1

class B(A):
    pass

class C(A):
    pass

B.x = 2
A.x = 3
print(A.x, B.x, C.x)

In this case, when x changes for A , it also changes for C as C inherits from A and x is not specifically declared in A . (srikanthtechnologies.com/blog/python/mro.aspx)


Comment on Disqus:

Comment on Twitter:

Question difficulty: 🔵🔵🔵🔵🔵