September 2013
Intermediate to advanced
350 pages
9h 38m
English
Back in Values, Variables, and Computer Memory, you learned that Python keeps track of each value in a separate object and that each object has a memory address. You can discover the actual memory address of an object using built-in function id:
| | >>> help(id) |
| | Help on built-in function id in module builtins: |
| | |
| | id(...) |
| | id(object) -> integer |
| | |
| | Return the identity of an object. This is guaranteed to be unique among |
| | simultaneously existing objects. (Hint: it's the object's memory |
| | address.) |
How cool is that? Let’s try it:
| | >>> id(-9) |
| | 4301189552 |
| | >>> id(23.1) |
| | 4298223160 |
| | >>> shoe_size = 8.5 |
| | >>> id(shoe_size) |
| | 4298223112 |
| | >>> fahrenheit ... |
Read now
Unlock full access