python - Trying to understand classes -
given code following:
class a(): x=1 class b() x=3 print x
how value of x in class b used in class a?
i example this:
class a: def add(): x=1 class b: def addmore(): y=1
how can value of y in class a
if understood right code, , access x variable:
class a(): x=1 class b(): x=3 ainstance = a() print ainstance.x '1' print ainstance.b.x '3'
Comments
Post a Comment