pg.typing.TupleKey¶
Accessible via pg.typing.TupleKey
.
- class TupleKey(index=None)[source]¶
Bases:
pg.typing.NonConstKey
Class that represents a key specification for tuple.
Example:
# Create a key spec that specifies item 0 of a tuple. key = pg.typing.TupleKey(0) assert key.match(0) assert not key.match(1)
Methods:
extend
(base)Extends this key spec on top of a base spec.
format
(**kwargs)Format this object.
match
(key)Returns whether this key spec can match against input key.
to_json
(**kwargs)Returns a plain Python value as a representation for this object.
Attributes:
Returns the index of tuple field that the key applies to.
- to_json(**kwargs)[source]¶
Returns a plain Python value as a representation for this object.
A plain Python value are basic python types that can be serialized into JSON, e.g:
bool
,int
,float
,str
,dict
(with string keys),list
,tuple
where the container types should have plain Python values as their values.