[Tutor] path issues

antonmuhin at rambler.ru antonmuhin at rambler.ru" <antonmuhin@rambler.ru
Thu May 1 06:43:02 2003


Hello Kirk,

Thursday, May 1, 2003, 8:55:21 AM, you wrote:

KB> ok, got a code problem.
KB>   os.remove('./lists/' + mylist)  # this deletes the subscriber file.
KB>   os.remove('./lists/' + mylist + '.*')   # remove all files with this

KB> blows out the script. Current dir is where the script is, the web 
KB> cgi-bin, and the /lists dir is immediately under it./ Produces this error:

KB> Traceback (innermost last):
KB>    File "/www/www.tinylist.org/cgi-bin/TLlistkill2.py", line 172, in ?
KB>      os.remove('./lists/' + mylist + '.*')      # remove all files...
KB> OSError: [Errno 2] No such file or directory: './lists/foolist.*'

KB> ok, is it simply that the language will not permit relative addressing 
KB> in the os module? It sure does in several others!

I suppose it doesn't allow deletion with wild cards: you are trying to
delete all the files in ./list/ with name footlist and any extension.

os.remove('./lists/' + mylist + '.someext') should work.

If you want to delete all this files, you may form a list of these
files and when delete one by one, or run some shell command to delete
them by mask.

-- 
Best regards,
 anton                            mailto:antonmuhin@rambler.ru