What's wrong with me/Python ?

Erik Max Francis max at alcyone.com
Tue Mar 13 11:59:42 EST 2001


Alexander Stirzel wrote:

> I just wrote a small script for killing some hanging netscape
> processes,
> the source is listed below.
> Now if I run this script I get this error message:
> 
> 8<----------- error message -----------------------------
> Traceback (most recent call last):
>   File "/usr/sbin/netscape-killer.py", line 11, in ?
>     splitted = string.split(line)
> NameError: There is no variable named 'string'
> 8<----------- error message -----------------------------
> 
> Now here's the script:
> 
> 8<------------ script -----------------------------------
> #!/usr/local/bin/python
> import os
> import time
	...

> What did I do wrong? And why does Python want a "variable named
> 'string'" here?

Because you're referencing `string' and it's never seen the variable
before.  You're missing an `import string' statement at the top.

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/  \ I am a gentlemen:  I live by robbing the poor.
\__/ George Bernard Shaw
    Kepler's laws / http://www.alcyone.com/max/physics/kepler/
 A proof of Kepler's laws.



More information about the Python-list mailing list