"0 in [True,False]" returns True

Mike Meyer mwm at mired.org
Tue Dec 13 11:07:29 EST 2005


"Fredrik Lundh" <fredrik at pythonware.com> writes:
> Duncan Booth wrote:
>> > For HTML attributes that don't have an explicit value (such as the
>> > SELECTED attribute in OPTION) the keyword argument to the function must
>> > have the value True
>> A better way to do this (given that HTML defines exactly which attributes
>> do not take a value) is to use the attribute name and simply generate the
>> attribute only if the value is non-false.
> footnote: strictly speaking, minimized attributes have values but no names;
> it's up to the parser to determine what attribute you're setting when you
> specify the value.
> (for example, in <img ismap>, "ismap" is the value, not the attribute name.
> it's up to the parser to figure out (from the DTD) that this value can only
> be used by the "ismap" attribute, and interpret it as <img ismap=ismap>)

But this isn't necessarilly true: <img alt=ismap> is perfectly legal.
I would say that ismap only has one valid value - "ismap", so the
parser knows that it should interepret a bare "ismap" as ismap=ismap,
which gets you the same behavior in the end.

      <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.



More information about the Python-list mailing list