Python's Core
The following table lists Python's built-in object types and some of the syntax used to code their literals.
Object type | Example literals/creation |
---|---|
Numbers | 1234, 3.1415, 3+4j, 0b111, Decimal(), Fraction() |
Strings | 'abcd', "test's", b'a\x01c', u'sp\xc4m' |
Lists | [1, [2, 'sss'], 4.5], list(range(10)) |
Dictionaries | {'food': 'abcd', 'test': 'yum'}, dict(hours=10) |
Tuples | (1, 'abcd', 4, 'U'), tuple('abcd'), named tuple |
Files | open('abc.txt'), open(r'C:\data\data.bin', 'wb') |
Sets | set('abc'), {'a', 'b', 'c'} |
Other core types | Booleans, types, None |