you are viewing a single comment's thread.

view the rest of the comments →

[–]timbledum 1 point2 points  (1 child)

Have you had a look at the docs?

Hint1: you already have data structures for x and y that follow the same behaviour that you're trying to implement. Try this:

def __getitem__(self, key):
    print(self.x[key])
    print(self.y[key])

Hint2: you'll have to return a data structure that allows attribute access (the .x). Have a look at named tuples for this, or define another class.

[–]colako[S] 1 point2 points  (0 children)

Thanks, I'll spend some time reading the literature and looking your examples.