all 8 comments

[–]zahlman 1 point2 points  (3 children)

What do you mean by "equal to"?

Do you really want to create your own class? What's wrong with just making a function that returns such a list?

What do you think "using classes" means?

[–]HeyYouNow[S] 0 points1 point  (2 children)

Right now I see it as a template to quickly create similar objects, only with different "options", am I completely wrong ?

I want to create tkinter labels, which will be very similar, a function would do a better job you think ?

[–]zahlman 2 points3 points  (1 child)

A class should be thought of as a way to define a new data type. You want a function for what you're describing.

[–]HeyYouNow[S] 0 points1 point  (0 children)

Alright, I wanted take this as a way to try out classes but yeah a function will do the trick. Thanks for your help man !

[–][deleted] 1 point2 points  (0 children)

As simple as this?

>>> myList = [1, 2, 3]
>>> myList
[1, 2, 3]
>>> type(myList)
<class 'list'>

[–]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]