[plug] [OT] python and spaces in path strings

bwarff bwarff at obsidian.com.au
Wed Dec 22 11:49:18 WST 2004


use the backspace character '\' to "escape" troublesome characters..
eg:
file = open('first\ last','wb')

to get the backspace itself, you use two of them such as '\\',
tho i definately wouldnt do that in a file name.


On Wed, 22 Dec 2004 10:53:55 +0800
<rpowersau at gmail.com> wrote:

> Hi,
> 
> Continuing on my adventure into Python (thanks again Cameron and
> James). I've got pieces 'working' now. So I decided to put them all
> together in a single script to make my life simple. But I've come
> across this annoying problem. (OK, I guess by definition all problems
> are annoying. :) )
> 
> If I enter a path on the command line, and the path has spaces, when
> that path gets sent to the remote site I get a 404 error. But if I
> type in %20 instead of spaces it works. Not that bad except I'm using
> that path to create a local directory. If I type in %20 then the local
> directory becomes "firstname%20lastname" instead of "firstname
> lastname".
> 
> Any pointers to good doco on this particular issue.  Or any "Oh that's
> easy, just use this..." answers?  :)
> 
> Some details:
> 
> I'm double quoting the command line path
>   myscript -u "http://192.168.1.90"  "FirstName LastName"
> 
> Here's how I'm creating the remote and local paths:
> 		remotef = url + arg + '/file%02d.jpg' %i
> 		localf = "./" + arg + '/file%02d.jpg' %i
> url is the -u option from the command line and arg is the name.
> 
> I'm using urllib.urlretrieve(remotef, localf) to get the file and save
> it locally.
> 
> Thanks.
> 
> -- 
> Regards,
> Russ
> _______________________________________________
> PLUG discussion list: plug at plug.linux.org.au
> http://spark.plug.linux.org.au/cgi-bin/mailman/listinfo/plug
> Committee e-mail: committee at plug.linux.org.au



More information about the plug mailing list