J
John Salerno
# Create new subdomain directory (with subdirectories) in my 1and1 folder
import os
import sys
subdirs = [r'\cgi-bin', r'\images', r'\styles']
#if len(sys.argv) == 1:
# subdomain = raw_input('Enter subdomain name: ')
#else:
# subdomain = sys.argv[1]
try:
subdomain = sys.argv[1]
except IndexError:
subdomain = raw_input('Enter subdomain name: ')
path = r'C:\Documents and Settings\John Salerno\My Documents\My
Webs\1and1\johnjsalerno.com\\' + subdomain
os.mkdir(path)
for subdir in subdirs:
os.mkdir(path + subdir)
Just a simple script I wrote as an experiment, and it works nicely
anyway. My two questions are these:
1. Like my other post, I'm wondering if it's okay to handle the ending
backlash as I did in path
2. Between the if block or the try block, which is more Pythonic? The
try block seems nicer because it doesn't have such an ugly-looking check
to make.
import os
import sys
subdirs = [r'\cgi-bin', r'\images', r'\styles']
#if len(sys.argv) == 1:
# subdomain = raw_input('Enter subdomain name: ')
#else:
# subdomain = sys.argv[1]
try:
subdomain = sys.argv[1]
except IndexError:
subdomain = raw_input('Enter subdomain name: ')
path = r'C:\Documents and Settings\John Salerno\My Documents\My
Webs\1and1\johnjsalerno.com\\' + subdomain
os.mkdir(path)
for subdir in subdirs:
os.mkdir(path + subdir)
Just a simple script I wrote as an experiment, and it works nicely
anyway. My two questions are these:
1. Like my other post, I'm wondering if it's okay to handle the ending
backlash as I did in path
2. Between the if block or the try block, which is more Pythonic? The
try block seems nicer because it doesn't have such an ugly-looking check
to make.