site.py confusion

George Trojan george.trojan at noaa.gov
Mon Jan 25 17:27:19 EST 2010


Inspired by the 'Default path for files' thread I tried to use 
sitecustomize in my code. What puzzles me is that the site.py's main() 
is not executed. My sitecustomize.py is
def main():
     print 'In Main()'
main()
and the test program is
import site
#site.main()
print 'Hi'
The output is
$ python try.py
Hi
When I uncomment the site.main() line the output is
$ python try.py
In Main()
Hi
If I change import site to import sitecustomize the output is as above. 
  What gives?
Adding to the confusion, I found 
http://code.activestate.com/recipes/552729/ which contradicts 
http://docs.python.org/library/site.html

George



More information about the Python-list mailing list