<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On 15 July 2013 14:53, Brett Cannon <span dir="ltr"><<a href="mailto:brett@python.org" target="_blank">brett@python.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
As long as you make sure that sys.path[0] is actually the script location then it will work (other things like .pth files, PYTHONSTARTUP, etc. could have changed things before your script started execution). But realize that a) in Python 3.3 the scripts location will be ./pip.py, not just pip.py, and b) if I get my way all paths will be absolute for __file__, so you will have to just associate '' with os.getcwd() and then search for the proper directory on sys.path.</blockquote>
</div><br>OK, that pretty much tells me that this is a bad idea. It's never going to be robust enough to work. I'm amazed actually that there's no way to say "don't add the script location to sys.path", even as a command line option. It seems like the sort of thing you'd want to make scripts robust, a bit like -S and -E.</div>
<div class="gmail_extra"><br></div><div class="gmail_extra" style>Paul</div></div>