pytilities.functions — Pytilities 1.2.0 documentation

### Navigation

- index
- modules |
- next |
- previous |
- Pytilities 1.2.0 documentation »
- API documentation »
- pytilities »

# pytilities.functions

`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 (class) – 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 (class) – 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.` `get_attr_value_or_none`(obj, name)

  Like get_attr_value, but returns None if attr does not exist

`pytilities.functions.` `has_attr_name`(obj, name)

  Like hasattr, but bypasses regular lookup.

  It checks __dict__s directly.

  Parameters: | obj (class) – 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 (class) – 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

### Navigation

- index
- modules |
- next |
- previous |
- Pytilities 1.2.0 documentation »
- API documentation »
- pytilities »