Go Back   Velocity Reviews > Newsgroups > Python
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

Python - string.Template issue

 
Thread Tools Search this Thread
Old 07-30-2009, 09:17 AM   #1
Default string.Template issue


Hello,

In the string.Template documentation
(http://docs.python.org/library/string.html) it's explained that if a
custom regular expression for pattern substitution is needed, it's
possible to override idpattern class attribute (whose default value is
[_a-z][_a-z0-9]*).

However, if the custom pattern that is needed is just uppercase
letters something like [A-Z]+ won't work because of the following line
in the _TemplateMetaclass class __init__ method:
cls.pattern = _re.compile(pattern, _re.IGNORECASE | _re.VERBOSE)

I would say that this is an error (IGNORECASE just shouldn't be there)
and that the line above should be:
cls.pattern = _re.compile(pattern, _re.VERBOSE)
and the default value for idpattern:
[_a-zA-Z][_a-zA-Z0-9]*

Do you agree on this? Is there any reason for the IGNORECASE option to
be passed to re.compile?

Best regards,
Javier


Javier Collado
  Reply With Quote
Old 08-02-2009, 12:36 AM   #2
Aahz
 
Posts: n/a
Default Re: string.Template issue
In article <mailman.3938.1248942327.8015.python->,
Javier Collado <> wrote:
>
>In the string.Template documentation
>(http://docs.python.org/library/string.html) it's explained that if a
>custom regular expression for pattern substitution is needed, it's
>possible to override idpattern class attribute (whose default value is
>[_a-z][_a-z0-9]*).
>
>However, if the custom pattern that is needed is just uppercase
>letters something like [A-Z]+ won't work because of the following line
>in the _TemplateMetaclass class __init__ method:
>cls.pattern = _re.compile(pattern, _re.IGNORECASE | _re.VERBOSE)
>
>I would say that this is an error (IGNORECASE just shouldn't be there)


Good point! I don't have an answer for you, but please file a report at
bugs.python.org to make sure it doesn't get lost.
--
Aahz () <*> http://www.pythoncraft.com/

"Many customs in this life persist because they ease friction and promote
productivity as a result of universal agreement, and whether they are
precisely the optimal choices is much less important." --Henry Spencer


Aahz
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Digital DIGEST - LIVE UPDATE Issue 41 Ablang DVD Video 0 01-05-2004 11:54 PM
Re: odd motherboard issue hootnholler A+ Certification 0 12-19-2003 06:34 AM
Digital DIGEST - LIVE UPDATE Issue 40 Ablang DVD Video 0 12-15-2003 02:45 PM
Digital DIGEST - LIVE UPDATE Issue 39 Ablang DVD Video 0 11-29-2003 02:17 AM
Digital DIGEST - LIVE UPDATE Issue 38 Ablang DVD Video 0 11-09-2003 01:31 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46