pytilities.functions

pytilities.functions._mangle_owner(owner, attribute)
pytilities.functions._mangle_str(cls_name, attribute)
pytilities.functions.get_annotations(obj, create=True)

Get a mutable dict of annotations on an object.

Changing values on the dict changes the annotations of the object.

It’s smart enough to handle properties, ...

Parameters:
  • obj (object) – the object to look for annotations on
  • create (bool) – if True, creates an annotations dict on the object if none was found
Returns:

annotations of the object or None if no annotations were found and create is False

Return type:

{object: object}

pytilities.functions.get_attr_name(obj, value)

Get name of attribute that has value, but bypass regular lookup.

It checks __dict__s directly.

Values are matched like: v == value

Parameters:
  • obj – the object to start looking for the attr on
  • value – value to look for
Raises AttributeError:
 

if attr wasn’t found

Returns:

attribute value as found in the __dict__

pytilities.functions.get_attr_value(obj, name)

Like getattr, but bypasses regular lookup.

It checks __dict__s directly.

Parameters:
  • obj – the object to start looking for the attr on
  • name (str) – name of the attribute to look for
Raises AttributeError:
 

if attr wasn’t found

Returns:

attribute value as found in the __dict__

pytilities.functions.has_attr_name(obj, name)

Like hasattr, but bypasses regular lookup.

It checks __dict__s directly.

Parameters:
  • obj – the object to start looking for the attr on
  • name (str) – name of the attribute to look for
Returns:

True if a dict contained name, False otherwise

Return type:

bool

pytilities.functions.has_attr_value(obj, value)

See if its dicts contain value as value, bypassing regular lookup.

It checks __dict__s directly.

Parameters:
  • obj – the object to start looking for the attr on
  • value – value to look for
Returns:

True if a dict.values contained value, False otherwise

Return type:

bool

Previous topic

pytilities.types._sequencetypemeta

Next topic

pytilities.infinity

This Page