[Newby] question about modules

James Stroud jstroud at mbi.ucla.edu
Fri Dec 10 15:00:06 EST 2004


Is it in "regex" or "re"? If in "re" then:

re.capwords(sentence)

If in "regex", then:

regex.capwords(sentence)


You can also do

from re import *

then you will not have to prefix. But careful not to clutter your namespace.

On Friday 10 December 2004 10:29 am, Jon wrote:
> Hi,
>
> The following four lines of code:
>
> import sys, os, re
> sentence = raw_input("Enter a sentence:  ")
> capwords (sentence)
> print sentence
>
> gives me the following error:  NameError: name 'capwords' is not defined
>
> As far as I can tell from the online docs, "capwords" should be defined in
> the built-in "regex" module.  Why is it telling me that capwords is not
> defined?


-- 
James Stroud, Ph.D.
UCLA-DOE Institute for Genomics and Proteomics
611 Charles E. Young Dr. S.
MBI 205, UCLA 951570
Los Angeles CA 90095-1570
http://www.jamesstroud.com/



More information about the Python-list mailing list