Home | Trees | Indices | Help |
|
---|
|
object --+ | _abcoll.Sized --+ | object --+ | | | _abcoll.Iterable --+ | object --+ | | | _abcoll.Container --+ | _abcoll.Set --+ | _abcoll.MutableSet --+ | Classes
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'
|
|||
Inherited from |
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Inherited from Inherited from Inherited from Inherited from |
|
|||
Inherited from Inherited from |
|
|||
Inherited from |
|
|
|
|
|
Add a class. This has no effect if the class is already present.
|
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.
|
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). |
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Thu Jul 9 18:29:53 2020 | http://epydoc.sourceforge.net |