class Complex:
realpart,imagpart=0,0
def __init__(self):
self.r = Complex.realpart
self.i = Complex.imagpart
x = Complex()
the above code works, x.r,x.i = (0,0), but when the class name is big, Class_name.Data_member way of accessing class data looks very redundant, is there any way to improve the class scoping, so I don't have to use Complex.imagpart? just use self.r = realpart?
complextype?C = ReallyReallyLongClassNameand usingC.realpartinstead? And consider if it should be a class-level constant anyway... (Edit @AdniDog: You're missing the point. VB isn't the only language that does scoping different from Python, and the class name is just an - albeit not very well-chosen - example)C = WayTooLongClassNameis a solution, but I don't remember ever having used something like this in Python. I chose VB as an example by intention, because statements there can get very long.x = 0+0j.