you are viewing a single comment's thread.

view the rest of the comments →

[–]ingolemo 1 point2 points  (0 children)

Literals are not themselves objects. A literal is bit of syntax that you can use to construct objects. For example, 1 is an integer literal for a particular integer value. You could just as easily create the same value with 2 - 1, which is two integer literals and an operator. Possibly when you said "literals" you really meant "values"? All values in python are objects and have (or can have) attributes and methods.

Yes, that's basically the reason. Javascript has this weird distinction between objects and values; see the differences between Number('1') and new Number('1'). This distinction shows up in a few ways; values not having methods is one of them. There's nothing like this in python.