class Classes(MutableSet):
Provides access to an element's class attribute as a set-like collection. Usage:
>>> el = fromstring('<p class="hidden large">Text</p>') >>> classes = el.classes # or: classes = Classes(el.attrib) >>> classes |= ['block', 'paragraph'] >>> el.get('class') 'hidden large block paragraph' >>> classes.toggle('hidden') False >>> el.get('class') 'large block paragraph' >>> classes -= ('some', 'classes', 'block') >>> el.get('class') 'large paragraph'
Method | __contains__ |
Undocumented |
Method | __init__ |
Undocumented |
Method | __iter__ |
Undocumented |
Method | __len__ |
Undocumented |
Method | add |
Add a class. |
Method | discard |
Remove a class if it is currently present. |
Method | remove |
Remove a class; it must currently be present. |
Method | toggle |
Add a class name if it isn't there yet, or remove it if it exists. |
Method | update |
Add all names from 'values'. |
Instance Variable | _attributes |
Undocumented |
Instance Variable | _get_class_value |
Undocumented |
Remove a class if it is currently present.
If the class is not present, do nothing.
Remove a class; it must currently be present.
If the class is not present, raise a KeyError.