This Page

syntax.attributelist

Defines classes for parsing attribute lists, which are comma-separated key/value pairs, with values in double quotes and preceded by the equals sign:

<name>="<value>", <name>="<value>", ..., <name>="<value>"
class AttributeListSyntax(attributes)[source]

Represents the abstract syntax of an attribute list, consisting of a collection of named attributes with associated values. Implements container semantics (via in and []) to allow easy access to these key-value mappings.

__init__(attributes)[source]

Initializes a new attribute list syntax object with the given dictionary of attribute-name-to-attribute-value mappings.

__contains__(key)[source]

Allows the use of the in keyword to determine whether an attribute with the given name is present in the list.

__getitem__(key)[source]

Allows the use of square-bracket notation to retrieve the value associated with a specified attribute.

__str__()[source]

Converts the syntax object back to text.

classmethod parse(text)[source]

Parses the given input text to produce a new AttributeListSyntax object.

Returns:the newly created attribute list structure.
Raises :a ParsingError if the syntax is invalid.