Next: Parenthesized forms Up: Atoms Previous: Identifiers (Names)

Literals

Python knows string and numeric literals:


literal:        stringliteral | integer | longinteger | floatnumber

Evaluation of a literal yields an object of the given type (string, integer, long integer, floating point number) with the given value. The value may be approximated in the case of floating point literals. See section for details.

All literals correspond to immutable data types, and hence the object's identity is less important than its value. Multiple evaluations of literals with the same value (either the same occurrence in the program text or a different occurrence) may obtain the same object or a different object with the same value.

(In the original implementation, all literals in the same code block with the same type and value yield the same object.)


guido@cwi.nl