[Python-Dev] Re: PEP: Defining Unicode Literal Encodings (revision 1.1)

M.-A. Lemburg mal@lemburg.com
Sat, 14 Jul 2001 21:57:29 +0200


Tim Peters wrote:
> 
> [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.

Well, I guess I would care enough :-) Martin has to change the PEP
though, since he's the PEP author (and currently on vacation if
I'm not mistaken).

I think that supporting the typical "key = value" format is
quite reasonable for setting flags in the compiler. The PEP's
original idea of replacing your "from __future__ import spam"
does not require this format, since is only needs to support
switches.

> > ...
> > 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).

Hmm, that looks a little cumbersome, but it would work (at least for
doc string extraction tools which import the module rather than
tokenize it).

-- 
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
______________________________________________________________________
Consulting & Company:                           http://www.egenix.com/
Python Software:                        http://www.lemburg.com/python/