Attributes

pytidyhtml5.Attr(Node node=None)

An HTML attribute of a pytidyhtml5.Node.

Getters

Attr.node

Related node.

Attr.name

Name of the attribute.

Returns

  • str – Name of the attribute

  • None – self is falsy

Attr.value

Value of the attribute

Returns

  • str – Value of the attribute

  • None – self is falsy

Attr.id

Numerical ID of the attribute.

Returns

  • TidyAttrId – ID of the attribute

  • int – The library reported an unknown value

  • None – self is falsy

Attr.is_event

Returns whether the attribute is a JavaScript handler, e.g. onclick.

Returns

  • bool – Yes or no

  • None – self is falsy

Methods

Attr.get_next(self)

The the next attribute of the Node.

Returns

  • Attr – The next attribute. Falsy if there was no further attribute.

  • None – self is falsy

Iterators

Attr.__iter__()

Yields name and value

Yields
  • str – Name and value

  • None – self is falsy

Miscellaneous

Attr.__bool__()

An Attr is truthy if the attribute exists and the Node did not expire.

Attr.__eq__()

An Attr compares equal if the underlying attributes are the same, i.e. same attribute in the same Node in the same Document.

Attr.__ne__()

Simply not (self == other)

Attr.__len__()

Length of the attribute iterator.

Returns

2 if bool(self) else 0

Return type

int

Getters as methods

All getters exist as methods, too:

pytidyhtml5.Attr.get_node(self)

Related node.

pytidyhtml5.Attr.get_name(self)

Name of the attribute.

pytidyhtml5.Attr.get_value(self)

Value of the attribute

pytidyhtml5.Attr.get_id(self)

Numerical ID of the attribute.

pytidyhtml5.Attr.get_is_event(self)

Returns whether the attribute is a JavaScript handler, e.g.