[ANN] markup.py - 1.2 - an HTML/XML generator
Walter Dörwald
walter at livinglogic.de
Tue Apr 4 14:02:08 EDT 2006
Peter Hansen wrote:
> Felipe Almeida Lessa wrote:
>> $ pwd
>> /usr/lib/python2.4/site-packages
>> $ grep -re klass . | wc -l
>> 274
>> $ grep -re class_ . | wc -l
>> 897
>
> How many of those "class_" instances are really just substrings of
> "__class__" and "class_name" and such? On my machine, I see a handful
> in the standard library, and _none_ in site-packages (which has only
> 1709 .py files, mind you).
>
>> For me that's enough. "class_" is used at least three times more than
>> "klass". Besides, as Scott pointed out, "class_" is prefered by the
>> guidelines too.
>
> Actually what he posted explicitly states that "cls" is preferred.
> Following that it says that one should considering appending _ if the
> name conflicts with a keyword (and one can assume it means "for all
> keywords other than class").
No, I think what it means is this: "Use cls as the name of the first
argument in a classmethod. For anything else (i.e. name that are not the
first argument in a classmethod) append an _, if it clashes with a
Python keyword.". So class_ is perfectly OK, if the Python argument maps
to the HTML attribute name.
Bye,
Walter Dörwald
More information about the Python-list
mailing list