I have several variables like:
class X(object):
...
class XY(X):
...
class XZ(X):
...
class XA(X):
...
y=XY()
z=[XZ(i) for i in range(1,10)]
a=[XA(i) for i in range(1,10)]
I would like to have a listlike view(including iteration and length) of the different variable y and the variables inside z and a.
this is for the sake of convenience w/out any worries about performance. I could just do
view = [self.y] + self.z + self.a
each time but that seems to be breaking the DRY principle.
Edit: to clarify that this isn't about taking the instance variables of a class. I just want a view class, probably implementing a list like interface that forwards to other variables. Or would it be better to make a closure that returns a view list when you call it(since I don't care about performance). Which is simpler/more pythonic/a better idea? How would I implement a list like forwarding class?., ect.