On 28.04.12 21:16, Brett Cannon wrote:


On Sat, Apr 28, 2012 at 04:08, Nick Coghlan <ncogh...@gmail.com <mailto:ncogh...@gmail.com>> wrote:

    On Sat, Apr 28, 2012 at 6:00 AM, Brett Cannon <br...@python.org
    <mailto:br...@python.org>> wrote:
    > I'm personally in favour of changing the insertion of '' to
    sys.path to
    > inserting the cwd when the interpreter is launched.

    I'm not, because it breaks importing from the interactive prompt if
    you change directory after starting the session.


Who does that? I mean what possible need do you have to start the interpreter in one directory, but then need to chdir somewhere else where you are doing your actual importing from, and in a way where you can't simply attach the directory you want to use into sys.path?


Well, it depends on which hat I'm wearing.

Scenario 1:
I am designing a big application. This application shall run without problems,
with disambiguated imports, and by no means should hit anything that is not
meant to be imported.
In this case, I need to remove '' from sys.path and replace it with an absolute entry.

Update: I see this works already unless "-c" and "-m" are present (hum).

Scenario 2:
I am playing with the application, want to try several modules, or even several versions of modules. I do use os.chdir() to get into a certain context, try imports, remove them again, chdir() to a different directory with a slightly changed module, et cetera. In this case, I need '' (or as has been mentioned '.') to have flexibility for testing,
debugging and exploration.

These scenarios are both perfectly valid for their use case, but they have pretty
different implication for imports, and especially for sys.path.

So the real question I was after was "can os.chdir() be freely used?"

It would be great to get "yes" or "no", but the answer is right now "it depends".

cheers - chris

--
Christian Tismer             :^)<mailto:tis...@stackless.com>
tismerysoft GmbH             :     Have a break! Take a ride on Python's
Karl-Liebknecht-Str. 121     :    *Starship* http://starship.python.net/
14482 Potsdam                :     PGP key ->  http://pgp.uni-mainz.de
work +49 173 24 18 776  mobile +49 173 24 18 776  fax n.a.
PGP 0x57F3BF04       9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
      whom do you want to sponsor today?   http://www.stackless.com/

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to