critique this little script, if you like
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

critique this little script, if you like

From: John Salerno <johnjsal@NOSPAMgmail.com>
Date: Mon May 01 2006 - 01:33:52 CEST

# 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.
Received on Mon May 1 00:48:31 2006