Re: making a valid file name...
You should use the s.translate() It's 100x faster: #Creates the translation table ValidChars = ":./,^0123456789abcdefghijklmnopqrstuvwxyz" InvalidChars = "".join([chr(i) for i in range(256) if not chr(i).lower() in ValidChars]) TranslationTable = "".join([chr(i) for i in range(256)]) def valid_filename(fname): return fname.translate(TranslationTable, InvalidChars) >> valid = >> ':./,^0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ' >> >> if I have a string called fname I want to go through each character in >> the filename and if it is not a valid character, then I want >> to replace >> it with a space. -- Ceci est une signature automatique de MesNews. Site : http://www.mesnews.net -- http://mail.python.org/mailman/listinfo/python-list
How do I separate my parameters with spawnv
Hi, I have a command line that works fine when I execute it directly: c:\\curl.exe -T c:\\upload.txt -u login:pwd ftp://ftp-myurl --ftp-ssl But when I try to use os.spawnv to excute it from my python code, it doesn't work at all. Here is my code: exe = "c:\\curl.exe" f = "c:\\upload.txt" logon = "login:pwd" url = "ftp://ftp-myurl"; import os os.spawnv(os.P_WAIT, exe, ["-T", f, "-u", logon, url, "--ftp-ssl"]) Does anyone know How I can execute my command line in python? Thanks and best regards, Fabio -- Ceci est une signature automatique de MesNews. Site : http://www.mesnews.net -- http://mail.python.org/mailman/listinfo/python-list
Re: How do I separate my parameters with spawnv
Thank you very much -- Ceci est une signature automatique de MesNews. Site : http://www.mesnews.net -- http://mail.python.org/mailman/listinfo/python-list
