Quoting Michael Murdock <[EMAIL PROTECTED]>: > On 4/13/05, Michael Murdock <[EMAIL PROTECTED]> wrote: > > Is there a way to have a Python script executed whenever Python starts > up? > > On 4/12/05, Mark Doukidis <[EMAIL PROTECTED]> wrote: > >> Try placing your code inside "sitecustomize.py". > >> This is run every time python is started. > > Thanks, Mark! This works fine. > > I was surprised when I found that my sitecustomize.py script imports > sys but sys isn't defined when I ask about it at the python prompt, so > I have to import it again. Why is that? >
You'll *probably* find that sitecustomize.py is run by being *imported*. This means that when sys is imported in ``sitecustomize.py`` a reference to the sys module is held - inside the sitecustomize namespace. The amendments you make to sys.path then affect anything else that *subsequently* uses sys.path. See if the interpreter holds a reference to ``sitecustomize``. (Can't test right now - sorry). If it *does* you'll be able to access sys through ``sitecustomize.sys`` - which is pointless, but shows you how namespaces work. Best Regards, Fuzzy http://www.voidspace.org.uk/python > Thanks again, > > ~Michael. > _______________________________________________ > PythonCE mailing list > PythonCE@python.org > http://mail.python.org/mailman/listinfo/pythonce > _______________________________________________ PythonCE mailing list PythonCE@python.org http://mail.python.org/mailman/listinfo/pythonce