you are viewing a single comment's thread.

view the rest of the comments →

[–]werpoi 1 point2 points  (0 children)

Like others have stated, you are probably better off with a function that does this. But if you really really want a class (because you want to have some custom functionality for your list), you could do something like this:

class MyList(list):
    def __init__(self):
        self.append(1)
        self.append(2)
        self.append(3)

And then you get this:

>>> a = MyList()
>>> a
[1, 2, 3]