[Newbie Problems] AttributeError from CGI script?

Doug Stanfield DOUGS at oceanic.com
Sun Jan 30 04:21:20 EST 2000


Its just a guess, but make sure you haven't made an assignment to string
someplace in your code.  In other words, I'm guessing you've done the
equivalent of:

[dougs at lawehana dougs]$ python
Python 1.5.2 (#1, Apr 18 1999, 16:03:16)  [GCC pgcc-2.91.60 19981201
(egcs-1.1.1  on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import string
>>> line = "the placeholder"
>>> string = "gum up"
>>> line = string.replace(line,"placeholder","works")
Traceback (innermost last):
  File "<stdin>", line 1, in ?
AttributeError: 'string' object has no attribute 'replace'

I'm guessing because my error message is somewhat different.  It sometimes
helps to know what platform and version you're using, and usually adding the
least amount of code that duplicates the error helps also.

Hope this helps.

-Doug-

> -----Original Message-----
> From: steve_w at localhost.localdomain
> [mailto:steve_w at localhost.localdomain]
> Sent: Saturday, January 29, 2000 7:15 PM
> To: python-list at python.org
> Subject: [Newbie Problems] AttributeError from CGI script?
> 
> 
> I'm trying to use Python in a CGI script for the first time and 
> have run into a problem I don't understand.  I get the subject
> error message when trying to do a string.replace using one of
> the values returned by the form that trigers the script.
> 
> The line of code looks like:
> 
> line = string.replace(line,"placeholder",form["target"].value)
> 
> I get an error message back saying:
> 
> Traceback (innermost last):
> File "[my script's file name]"
>    line = string.replace(line,"placeholder",form["target"].value)
> AttributeError: replace
> 
> Could someone help me figure out what this error message means?
> 
> Thanks in advance,
> 
> Steve Wall
> steve_w at visi.com
> -- 
> http://www.python.org/mailman/listinfo/python-list
> 




More information about the Python-list mailing list