weird str error

Dave Angel davea at ieee.org
Tue Sep 15 12:42:43 EDT 2009


daved170 wrote:
> Hi everybody,
> I'm using SPE 0.8.3.c as my python editor.
> I'm using the str() function and i got a very odd error.
>
> I'm trying to do this: print str("HI")
> When i'm writing this line in the shell it prints: HI
> When it's in my code (it's the only line) i'm getting the following
> error:
>
> file "c:\Python25\lib\local.py" line 242, in str
>    return format("%.12g",val)
>
> file "c:\Python25\lib\local.py" line 145, in format
>    formatted = percent % value
>    TypeError, float argument required
>
> any idea? It's worked for the entire day and unfortunately when i
> started my testing it raised this erroe/
>
>   
I should start by asking why you're using using str() on a string 
literal?  It would seem to just be a waste of time to convert a string 
to a string.

Next, I'll have to insist that you copy/paste your error messages to the 
email;  by retyping it you got the wrong file name.  The file with that 
line in it is locale.py

So now, you have a *locale* problem.  Somebody other than I will have to 
help.  And all the effort I put in before noticing your typo is wasted.

You'd better describe your environment more thoroughly.  Python version, 
OS, locale, and just how you're running this script.  You said it's "the 
only line" so are you omitting the shebang line?  Perhaps you're running 
on Windows?  If so, you can copy from a cmd window using 
right-click-drag, at least if Quick-Edit is on.


DaveA




More information about the Python-list mailing list