def rotate_attribute(obj, attr_name, values_deque):
    """Rotate attribute value between those provided.

    This function is meant to be turned into partials
    by the get_attribute_rotator function for more efficient
    usage.

    Tip: passing a deque with two values creates a simple
    very useful toggle.

    obj (any object which can have attributes set on it)
        object whose attribute is used to hold the value.
    attr_name (string)
        name of the attribute where to store the value.
    values_deque (deque containing any python object/values)
        values between which to toggle.

    >>> class Obj: pass
    ...
    >>> obj = Obj()
    >>> d = deque(["a", "b", "c"])
    >>> rotate = partial(rotate_attribute, obj, "char", d)

    >>> rotate()
    >>> obj.char
    'b'
    >>> rotate()
    >>> obj.char
    'c'

    >>> obj.char = "b"
    >>> rotate()
    >>> obj.char
    'a'

    Notice in the last doctest section that even when we
    set the char attribute to "b" the next value of char
    after rotating is "a". This is because the assignement
    follows the rotation of the deque, without taking into
    consideration the current value.

    If you need a function that takes into account the
    current value before assigning a new one you should use
    the get attribute toggler function.
    """
    values_deque.rotate(-1)
    setattr(obj, attr_name, values_deque[0])
Rotate attribute value between those provided.

    This function is meant to be turned into partials
    by the get_attribute_rotator function for more efficient
    usage.

    Tip: passing a deque with two values creates a simple
    very useful toggle.

    obj (any object which can have attributes set on it)
        object whose attribute is used to hold the value.
    attr_name (string)
        name of the attribute where to store the value.
    values_deque (deque containing any python object/values)
        values between which to toggle.

    >>> class Obj: pass
    ...
    >>> obj = Obj()
    >>> d = deque(["a", "b", "c"])
    >>> rotate = partial(rotate_attribute, obj, "char", d)

    >>> rotate()
    >>> obj.char
    'b'
    >>> rotate()
    >>> obj.char
    'c'

    >>> obj.char = "b"
    >>> rotate()
    >>> obj.char
    'a'

    Notice in the last doctest section that even when we
    set the char attribute to "b" the next value of char
    after rotating is "a". This is because the assignement
    follows the rotation of the deque, without taking into
    consideration the current value.

    If you need a function that takes into account the
    current value before assigning a new one you should use
    the get attribute toggler function.
    
nodezator/ourstdlibs/behaviour.py