Shell quoting as part of the standard library?

Oren Tirosh oren-py-l at hishome.net
Sun Dec 14 04:10:40 EST 2003


On Sat, Dec 13, 2003 at 02:39:52PM -0800, David M. Wilson wrote:
> Hello fellow users!
> 
> I've been using Python in a couple of different environments for a few
> years now. I have quite often found that I have needed to deal with
> filenames which may contain characters that confuse the UNIX shell
> (space and double quote in particular).

The best solution is often to bypass the shell (os.system) and execute 
the external command you want directly with os.spawnv. In this case the 
arguments are passed as a list of strings rather than a space-separated
string and therefore need no quoting.

    Oren





More information about the Python-list mailing list