I am more experienced with Java and trying to write a script for a server I have. I need to learn Python anyway, so I am attempting to do it in python. I am not completely lost, but just puzzled why it would do this.
Here is the code

#!/usr/bin/env python
import sys
import os
from optparse import OptionParser

#displays help
usage = "usage:%prog [options] arg"
description = "Creates a Django project with the necessary files to get a website running on a apache server."
parser = OptionParser(usage=usage, description=description)

parser.add_option("-q", "--quiet",
                  action="store_false", dest="verbose", default=True,
                  help="don't print status messages to stdout")

(options, args) = parser.parse_args()
if len(args) != 1:
        parser.error("Incorrect number of arguments")
#writes django.wsgi
def writeFile(*args):
    site = str(args[0])
    apacheFile = file('django.wsgi', 'w')
    print >> apacheFile, "import os\nimport sys\n\nsys.path.append('/var/www/')\n\n"
    print >> apacheFile, "os.evniron['PYTHON_EGG_CACHE'] = '/var/www/%s/.python-egg'\n" % site
    print >> apacheFile, "os.environ['DJANGO_SETTINGS_MODULE'] = '%s.settings'\n" % site.strip('[]')
    print >> apacheFile, "import django.core.handlers.wsgi\n"
    print >> apacheFile, "application = django.core.handlers.wsgi.WSGIHandler()"
if __name__ == "__main__":

It writes the file as such. I put a strip in there just to see if it would work.
if I did something like this print args[0] it outputs if I do site = str(args[0]) it outputs test. I did the exact same thing in the file write it doesn't like it. here is the output

import os
import sys


os.evniron['PYTHON_EGG_CACHE'] = '/var/www/['test']/.python-egg'

os.environ['DJANGO_SETTINGS_MODULE'] = ''test'.settings'

import django.core.handlers.wsgi

application = django.core.handlers.wsgi.WSGIHandler()
This question has already been answered. Start a new discussion instead.