Python

class todd.patches.py_.AttrDict[source]

Bases: UserDict[Any, Any]

class todd.patches.py_.DictAction[source]

Bases: Action

argparse action to parse arguments in the form of key-value pairs.

Examples

>>> parser = argparse.ArgumentParser()
>>> parser.add_argument('--dict', action=DictAction)
DictAction(...)
>>> parser.parse_args('--dict key1::value1 key2::value2'.split())
Namespace(dict={'key1': 'value1', 'key2': 'value2'})
__init__(*args, **kwargs)[source]
Return type:

None

class todd.patches.py_.Formatter[source]

Bases: Formatter

__init__(*args, **kwargs)[source]
Return type:

None

class todd.patches.py_.NonInstantiableMeta[source]

Bases: type

class todd.patches.py_.classproperty[source]

Bases: object

__init__(method)[source]
Parameters:

method (Callable[[Any], Any])

Return type:

None

todd.patches.py_.decode_filename(f)[source]
Parameters:

f (str)

Return type:

str

todd.patches.py_.del_(obj, attr)[source]

Delete an attribute of an object.

Parameters:
  • obj (Any) – The object to delete the attribute from.

  • attr (str) – The attribute name.

Return type:

None

todd.patches.py_.descendant_classes(cls)[source]
Parameters:

cls (type)

Return type:

list[type]

todd.patches.py_.encode_filename(s)[source]
Parameters:

s (str)

Return type:

str

todd.patches.py_.exec_(source, **kwargs)[source]
Parameters:

source (str)

Return type:

dict[str, Any]

todd.patches.py_.get_(obj, attr, default=Ellipsis)[source]
Parameters:
Return type:

Any

todd.patches.py_.get_classes(*args, **kwargs)[source]
Return type:

set[type[Any]]

todd.patches.py_.get_named_classes(module, *args)[source]
Parameters:

module (ModuleType)

Return type:

dict[str, type[Any]]

todd.patches.py_.has_(obj, name)[source]

Check if an object has an attribute.

Parameters:
  • obj (Any) – The object to check.

  • name (str) – The attribute name.

Returns:

Whether the object has the attribute.

Return type:

bool

todd.patches.py_.import_module(name, *args, **kwargs)[source]
Parameters:

name (str)

Return type:

ModuleType | None

todd.patches.py_.json_dump(obj, f, *, compact=True, **kwargs)[source]
Parameters:
Return type:

None

todd.patches.py_.json_load(f, **kwargs)[source]
Parameters:

f (Any)

Return type:

Any

todd.patches.py_.map_(data, f)[source]
Parameters:
Return type:

Any

todd.patches.py_.remove_prefix(string, prefix)[source]
Parameters:
Return type:

str

todd.patches.py_.remove_suffix(string, suffix)[source]
Parameters:
Return type:

str

todd.patches.py_.run(args)[source]
Parameters:

args (str)

Return type:

str

todd.patches.py_.set_(obj, attr, value)[source]

Set an attribute of an object.

Parameters:
  • obj (Any) – The object to set the attribute on.

  • attr (str) – The attribute name.

  • value (Any) – The value to set.

Raises:

ValueError – If the attribute is invalid.

Return type:

None