[Python-Dev] Re: Re: Alternative
ImplementationforPEP292:SimpleStringSubstitutions
Fredrik Lundh
fredrik at pythonware.com
Sat Sep 11 08:52:06 CEST 2004
Raymond Hettinger wrote:
> """Placeholders must be a valid Python identifier (containing only ASCII
> alphanumeric characters and an underscore). If an unbraced identifier
> ends with a non-ASCII alphanumeric character, such as the latin letter n
> with tilde in $mañana, then a ValueError is raised for the specious
> identifier.
so why keep the python identifier limitation? the RE engine you're using to
parse the template has a concept of "alphanumeric character". just define
the placeholder syntax as "one or more alphanumeric characters or under-
scores" (\w+), use re.UNICODE if the template is created from a unicode
string, and you're done.
this doesn't mean that people *have* to use non-ASCII characters, of course.
but if they do, things just work.
</F>
More information about the Python-Dev
mailing list