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

rpowersau at gmail.com rpowersau at gmail.com
Wed Dec 22 10:53:55 WST 2004


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



More information about the plug mailing list