user1971598
user1971598

Reputation:

Nature of Python Values, need a clarification

I just finished reading http://python.net/crew/mwh/hacks/objectthink.html and http://nedbatchelder.com/text/names.html.

Just have a question now, are Python values always Objects (Are objects the only things that names can be bound to?) and moreover, are Objects the only game in PyTown...as the language doesn't have primitives, correct?

Upvotes: 0

Views: 63

Answers (1)

Martijn Pieters
Martijn Pieters

Reputation: 1124558

It's objects all the way down, yes.

Integers, for example, have methods:

>>> 1 .__str__
<method-wrapper '__str__' of int object at 0x104ad7820>

and so do functions:

>>> def foo(): pass
... 
>>> foo.__str__
<method-wrapper '__str__' of function object at 0x104e62830>

Upvotes: 3

Related Questions