Converting argv to variable

Terry Reedy tjreedy at udel.edu
Sat Jul 22 15:06:13 EDT 2006


"tgiles" <tgiles at gmail.com> wrote in message 
news:1153573721.313812.150510 at m73g2000cwd.googlegroups.com...
> (now that I've posted in the wrong flipping newsgroup the first thing,
> here's my question to the lovely python folks)
>
> I've taken a year off (or so) using Python and the first thing I run
> into utterly stumped me. Been too long and none of the searches I've
> done seems to have helped any.
> Basically, I'm trying to create a little script which will make a new
> directory, using the argument passed to it to give the directory a
> name:
>
> #!/usr/bin/python
> import sys, os
> newDirectory = str(sys.argv[1:])

If you are only going to make one dir at a time, newDir = sys.argv[1]

> currentPath =  str(os.getcwd())
> create =  currentPath + '/' + newDirectory

os.path has platform-independent function to do this

tjr






More information about the Python-list mailing list