class documentation

class Classes(MutableSet):

View In Hierarchy

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
def __contains__(self, name):

Undocumented

def __init__(self, attributes):

Undocumented

def __iter__(self):

Undocumented

def __len__(self):

Undocumented

def add(self, value):

Add a class.

This has no effect if the class is already present.

def discard(self, value):

Remove a class if it is currently present.

If the class is not present, do nothing.

def remove(self, value):

Remove a class; it must currently be present.

If the class is not present, raise a KeyError.

def toggle(self, value):

Add a class name if it isn't there yet, or remove it if it exists.

Returns true if the class was added (and is now enabled) and false if it was removed (and is now disabled).

def update(self, values):
Add all names from 'values'.
_attributes =

Undocumented

_get_class_value =

Undocumented