Object¶
Represents a Python object.
Declaration
@dynamicMemberLookup
class Object
Discussion
This class implements a dynamic member lookup, which allows you to access attributes of the Python object through this class as if it were a real Swift member. The dynamic member lookup subscript returns an optional Object, which is nil in case of AttributeError.
This class also conforms to Equatable and Comparable which allows comparaison with ==, <, > and other operators. It conforms to Sequence which makes the object iterable and to Hashable through the object’s identity. CustomStringConvertible provides description and CustomDebugStringConvertible provides debugDescription which correspond to __str__ and __repr__ respectively.
Members
The PyObject * pointer
The Python version to which this object belongs.
A holder for the CPython C symbols.
Init / Deinit
Initializes from an optional Object and throws unhandled if the object is nil.
Dynamic member lookup
Returns an attribute by name and throws if an error occurs.
Sets an attribute and throws if an error occurs.
Sets or returns an attribute by name.
Subscript
Returns an item corresponding to the given key(s) and throws an error if it fails.
Sets an item to a key and throws an error if it fails.
Returns an item corresponding to the given key(s).
Callable
Calls the receiver.
Calls the receiver.
Calls the receiver.
Calls the receiver.
Calls the receiver.
Calls the receiver.
Parsing
Parses the receiver into a Swift type conforming to Parsable and throws if the conversion failed.
Comparable
Conforms to
SendableEquatableComparableSequenceHashableCustomStringConvertibleCustomDebugStringConvertible