pg.typing.ConstStrKey#

Accessible via pg.typing.ConstStrKey.

class ConstStrKey(text)[source]#

Bases: KeySpecBase, pg.object_utils.StrKey

Class that represents a constant string key.

Example:

key = pg.typing.ConstStrKey('x')
assert key == 'x'
assert hash(key) == hash('x')

Methods:

format(**kwargs)

Format this object.

match(key)

Whether can match against an input key.

to_json(**kwargs)

Returns a plain Python value as a representation for this object.

Attributes:

is_const

Returns whether current key is const.

text

Text of this const string key.

format(**kwargs)[source]#

Format this object.

Return type:

str

property is_const: bool[source]#

Returns whether current key is const.

match(key)[source]#

Whether can match against an input key.

Return type:

bool

property text: str[source]#

Text of this const string key.

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.

Return type:

Dict[str, Any]

Parameters:

**kwargs – Keyword arguments as flags to control JSON conversion.

Returns:

A plain Python value.