PEP: Defining Unicode Literal Encodings (revision 1.1)

Tim Peters tim.one at home.com
Sat Jul 14 21:37:39 CEST 2001


[M.-A. Lemburg]
> ...
> I'm not picky about the '='; if people don't want it, I'll
> happily drop it from the PEP. The only reason I think it may be
> worthwhile adding it is because it simply looks right:
>
> directive unicodeencoding = 'latin-1'
>
> rather than
>
> directive unicodeencoding 'latin-1'

The hangup is finding someone who cares enough <0.9 wink> to change the text
and implementation of the directive PEP.  There was no significant debate
about the proposed directive syntax in that, and in years past similar
crusades that did attract debate floundered on the inability to reach
consensus on overall syntax; it's not a good sign that the first proposed
use wanted syntax the PEP doesn't support.

> ...
> Still, if people would like to use Unicode literals for module
> doc-strings, then they should place the directive *before* the
> doc-string accepting that this could break some tools (the PEP
> currently does not restrict the placement of the directive).
> Alternatively, we could allow placing the directive into a
> comment, e.g.
>
> #!/usr/local/python
> #directive unicodeencoding = 'utf-8'
> u"""
>      This is a Unicode doc-string
> """

Another alternative:

#!/usr/local/python
directive unicodeencoding 'utf-8'

__doc__ = u"""
        This is a Unicode doc-string
"""

That is, the module docstring is just the module's __doc__ attr, and that
can be bound explicitly (a trick I've sometimes use for *computed* module
docstrings).





More information about the Python-list mailing list