Class Attrs
object --+    
         |    
     tuple --+
             |
            Attrs
Immutable sequence type that stores the attributes of an element.
Ordering of the attributes is preserved, while access by name is also
supported.
>>> attrs = Attrs([('href', '#'), ('title', 'Foo')])
>>> attrs
Attrs([('href', '#'), ('title', 'Foo')])
>>> 'href' in attrs
True
>>> 'tabindex' in attrs
False
>>> attrs.get('title')
'Foo'
Instances may not be manipulated directly. Instead, the operators | and
- can be used to produce new instances that have specific attributes
added, replaced or removed.
To remove an attribute, use the - operator. The right hand side can be
either a string or a set/sequence of strings, identifying the name(s) of
the attribute(s) to remove:
>>> attrs - 'title'
Attrs([('href', '#')])
>>> attrs - ('title', 'href')
Attrs()
The original instance is not modified, but the operator can of course be
used with an assignment:
>>> attrs
Attrs([('href', '#'), ('title', 'Foo')])
>>> attrs -= 'title'
>>> attrs
Attrs([('href', '#')])
To add a new attribute, use the | operator, where the right hand value
is a sequence of (name, value) tuples (which includes Attrs
instances):
>>> attrs | [('title', 'Bar')]
Attrs([('href', '#'), ('title', 'Bar')])
If the attributes already contain an attribute with a given name, the value
of that attribute is replaced:
>>> attrs | [('href', 'http://example.org/')]
Attrs([('href', 'http://example.org/')])
    | bool | 
        
          | __contains__(self,
        name) Return whether the list includes an attribute with the specified
name.
 |  |  | 
    |  | 
        
          | __getitem__(self,
        i) Return an item or slice of the attributes list.
 |  |  | 
    |  | 
        
          | __getslice__(self,
        i,
        j) Return a slice of the attributes list.
 |  |  | 
    | Attrs | 
        
          | __or__(self,
        attrs) Return a new instance that contains the attributes in
 attrsin
addition to any already existing attributes. Any attributes in the new
set that have a value ofNoneare removed. |  |  | 
    |  |  | 
    | Attrs | 
        
          | __sub__(self,
        names) Return a new instance with all attributes with a name in
 namesare
removed. |  |  | 
    | object | 
        
          | get(self,
        name,
        default=None) Return the value of the attribute with the specified name, or the
value of the
 defaultparameter if no such attribute is found. |  |  | 
    | tuple | 
        
          | totuple(self) Return the attributes as a markup event.
 |  |  | 
  
    | Inherited from tuple:__add__,__eq__,__ge__,__getattribute__,__getnewargs__,__gt__,__hash__,__iter__,__le__,__len__,__lt__,__mul__,__ne__,__new__,__rmul__,__sizeof__,count,index Inherited from object:__delattr__,__format__,__init__,__reduce__,__reduce_ex__,__setattr__,__str__,__subclasshook__ | 
  
    | Inherited from object:__class__ | 
| 
  Return whether the list includes an attribute with the specified
name.| __contains__(self,
        name)
    (In operator)
 |  |  
    Returns: boolTrueif the list includes the attributeOverrides:
        tuple.__contains__
     | 
 
| 
  | __getitem__(self,
        i)
    (Indexing operator)
 |  |  Return an item or slice of the attributes list. 
>>> attrs = Attrs([('href', '#'), ('title', 'Foo')])
>>> attrs[1]
('title', 'Foo')
>>> attrs[1:]
Attrs([('title', 'Foo')])
    Overrides:
        tuple.__getitem__
     | 
 
| 
  | __getslice__(self,
        i,
        j)
    (Slicling operator)
 |  |  Return a slice of the attributes list. 
>>> attrs = Attrs([('href', '#'), ('title', 'Foo')])
>>> attrs[1:]
Attrs([('title', 'Foo')])
    Overrides:
        tuple.__getslice__
     | 
 
| 
  Return a new instance that contains the attributes in| __or__(self,
        attrs)
    (Or operator)
 |  |  attrsin
addition to any already existing attributes. Any attributes in the new
set that have a value ofNoneare removed.
    Returns: Attrsa new instance with the merged attributes | 
 
| 
  repr(x)| __repr__(self)
    (Representation operator)
 |  |  
    Overrides:
        object.__repr__
        (inherited documentation) | 
 
| 
  Return a new instance with all attributes with a name in| __sub__(self,
        names)
    (Subtraction operator)
 |  |  namesare
removed.
    Parameters:
        names- the names of the attributes to removeReturns: Attrsa new instance with the attribute removed | 
 
| 
  Return the value of the attribute with the specified name, or the
value of the| get(self,
        name,
        default=None)
   |  |  defaultparameter if no such attribute is found.
    Parameters:
        name- the name of the attributedefault- the value to return when the attribute does not existReturns: objectthe attribute value, or the defaultvalue if that attribute
does not exist | 
 
| Return the attributes as a markup event. The returned event is a TEXT event, the data is the value of all
attributes joined together. 
>>> Attrs([('href', '#'), ('title', 'Foo')]).totuple()
('TEXT', '#Foo', (None, -1, -1))
    Returns: tuplea TEXT event |