For example, if I am working with non-HTML content (such as DITA XML source), then that will have its own conventions for list-of-strings attributes. For example, DITA has profiling condition attributes that are also multi-value:
I am completely fine with not using "class" in the name. (I am just used to XML::Twig's methods.) The terminology used in the BS4 documentation is "multi-valued attributes" so we probably use something consistent with that. Some ideas are:
What would the subclassed-list UI look like? How would it handle the addition of a value to an attribute that doesn't exist yet? Could it handle addition/removal of both single values and lists of values?
Your four-item summary of the requested functionality is spot-on.
Indeed, these methods could (and should) support other attributes, such as:
====
def add_class(self, these_classes, attname='class'):
...
def remove_class(self, these_classes, attname='class'):
...
====
For example, if I am working with non-HTML content (such as DITA XML source), then that will have its own conventions for list-of-strings attributes. For example, DITA has profiling condition attributes that are also multi-value:
==== add_class( 'expert' , attname='audience')
dita_tag.
====
I am completely fine with not using "class" in the name. (I am just used to XML::Twig's methods.) The terminology used in the BS4 documentation is "multi-valued attributes" so we probably use something consistent with that. Some ideas are:
==== value(' foo') value([ 'foo', 'bar'])
tag.add_
tag.remove_
tag.add_ multivalue( 'foo') multivalue( ['foo', 'bar'])
tag.remove_
====
If the attribute name argument is required (instead of defaulting to 'class'), it would make the methods' purposes clearer in context:
==== value(' foo', attname='class') value([ 'foo', 'bar'], attname='class')
tag.add_
tag.remove_
tag.add_ multivalue( 'foo', attname='class') multivalue( ['foo', 'bar'], attname='class')
tag.remove_
====
or
==== value(' class', 'foo') value(' class', ['foo', 'bar'])
tag.add_
tag.remove_
tag.add_ multivalue( 'class' , 'foo') multivalue( 'class' , ['foo', 'bar'])
tag.remove_
====
What would the subclassed-list UI look like? How would it handle the addition of a value to an attribute that doesn't exist yet? Could it handle addition/removal of both single values and lists of values?