Can anyone explain in simple words what an attribute in Python language is?
For instance what can I say about
list.append(x)
which adds
Properties are just one thing that can be modeled using attributes. As you say, the operation of adding to the end of a list is another such thing. This has a rather straightforward interpretation in Python; since functions are first-class values, they can be stored as the value of an attribute like any other type. Here, list.append
is simply a function, which when called adds its argument to the end of list
. You can see that it doesn't matter by what name you call the function. The following are identical in behavior:
list.append(5)
f = list.append; f(5)
In both cases, the same bound method is called with an argument of 5.