String .lower, .upper, and .title in a Python Script
Okay, here is a strange bit of behavior in a Zope (and python for that matter, as I'm working with a python script. In the string module, there is: .lower(), .upper(), .capitalize(), and .title(). In a python script... myStr = string.lower(myStr) # Works! myStr = string.upper(myStr) # Works! myStr = string.capitalize(myStr) # Works! myStr = string.title(myStr) # DOES NOT WORK! If you look up .title() in the python manual (its on page 8 of the Library Reference Manual), it has .title() as one of the string functions (presumably in the string module). Unfortunately, if I run .title() in my stript, I get an AttributeError for "title". Not so with the others. Am I missing something? TIA, Ron
On Thu, Dec 13, 2001 at 07:36:01PM +0000, complaw@hal-pc.org wrote:
Unfortunately, if I run .title() in my stript, I get an AttributeError for "title". Not so with the others.
This is because title is a commonly-used (if not universal) property of most objects, perhaps? -- Mike Renfro / R&D Engineer, Center for Manufacturing Research, 931 372-3601 / Tennessee Technological University -- renfro@tntech.edu
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of complaw@hal-pc.org
In the string module, there is: .lower(), .upper(), .capitalize(), and .title().
Am I missing something?
Yeah. In Python 2, strings have the above methods, but the string module does not include a 'title' function. If you're running Python 2.1 with Zope 2.4+, you can use the string method. For example:
mystr = 'the no spin zone' mystr.title() 'The No Spin Zone'
No need to import the string module. _______________________ Ron Bickers Logic Etc, Inc.
participants (3)
-
complaw@hal-pc.org -
Mike Renfro -
Ron Bickers