
Specific Built-in Types
|
11
Slicing: S[i:j:k]
• If present, the third item k is a stride: added to the offset
of each item extracted.
•
S[::2] is every other item in sequence S.
•
S[::-1] is sequence S reversed.
•
S[4:1:-1] fetches from offsets 4 up to, but not including,
1, reversed.
Other
• Concatenation, repetition, and slicing return new objects
(not always for tuples).
Specific Built-in Types
This section covers numbers, strings, lists, dictionaries,
tuples, files, and other built-in types. Compound datatypes
(e.g., lists, dictionaries, and tuples) can nest inside each other
arbitrarily, and as deeply as required.
Numbers
This section covers basic number types (integers, floating-
point), as well as more advanced types (complex, unlimited-
precision long integers). Numbers are always immutable
(unchangeable).
Literals
Numbers are written in a variety of numeric constant forms.
1234, -24, 0
Normal integers (C longs, at least 32 bits)
99999999L, 42l
Long integers (unlimited size)
1.23, 3.14e-10, 4E210, 4.0e+210, 1., .1
Floating-point (C doubles)