Search notes:

Python built-in types

Every object is associated with a type. The type deteremines what the object represents (and by extension the type's capabilities (methods and members))
The type of an object can be queried with the built-in function type:
>>> num = 42
>>> pie = 3.14156

>>> type(num)
<class 'int'>

>>> type(pie)
<class 'float'>

Some built-in types

builtin_function_or_method
bytes
code
coroutine
dict
ellipsis
frozenset
int stores an arbitrarily large (in Python 3, that is) integral numerical value.
float
iterator
list
list_iterator
method
NoneType
set
slice returns slice object
str A representation of a string
traceback
tuple
type represents a type itself.

Callable types

Callable types are types on which the function call operator can be applied.
Callable types include
See also callable objects

Represenation of lists and dicts

A list and a dict are represented with the spcial symbols: the list with square brackets, the dict with curly braces:
>>> dict()
{}
>>> list()
[]
The bytes type is represented with single apostrophes that is prefixed with a b:
>>> bytes()
b''

TODO

sequence

A sequence is an iterable with the methods __getitem__() (for accessing elements) and __len__().
Built-in sequences include
A dict also privides __getitem__() and __len__(), yet it is considered to be a mapping.

collections.abc.Sequence

The collections.abc.Sequence abstract base class is a sequence that also provides the following methods:
  • count()
  • index()
  • __contains__()
  • __reversed__()
Objects with such an interface can be registered with register().

loader

A loader is typically returned by a finder and is able to load a module through the load_module() method that a loader is required to implement.

NoneType

NoneType has one value: None which is typically used to represent the absence of any value (much like null in SQL).
>>> type(None)
<class 'NoneType'>
>>> None = 42
SyntaxError: cannot assign to None

Modules / packages

A module objects have a namespace in which other objects are located.
Modules are used to manage code units.
Modules are created with import.
A package is a module that contains other modules or (sub-)packages.
A module with a __path__ attribute is a package.

See also

The built-in function type(…)
The CPython source files that implement built in types (seem to be) stored under the Objects/ directory.
Type hierarchy

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1745040113, '3.141.41.251', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/Python/types/index(176): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78