Re: Why doesn't Python remember the initial directory?

2012-08-21 Thread John Roth
On Sunday, August 19, 2012 7:57:46 PM UTC-6, kj wrote: This means that no library code can ever count on, for example, being able to reliably find the path to the file that contains the definition of __main__. If you want to find that, look up __main__ in sys.modules and then look at the

Re: Why doesn't Python remember the initial directory?

2012-08-20 Thread Mark Lawrence
On 20/08/2012 02:57, kj wrote: In roy-ca6d77.17031119082...@news.panix.com Roy Smith r...@panix.com writes: In article k0rj38$2gc$1...@reader1.panix.com, kj no.em...@please.post wrote: As far as I've been able to determine, Python does not remember (immutably, that is) the working directory

Re: Why doesn't Python remember the initial directory?

2012-08-20 Thread Mark Lawrence
On 20/08/2012 04:04, alex23 wrote: My apologies for any double-ups and bad formatting. The new Google Groups interface seems to have effectively shat away decades of UX for something that I can only guess was generated randomly. It's very useful for reporting spam. Otherwise Thunderbird is

Re: Why doesn't Python remember the initial directory?

2012-08-20 Thread andrea crotti
2012/8/20 kj no.em...@please.post: In roy-ca6d77.17031119082...@news.panix.com Roy Smith r...@panix.com writes This means that no library code can ever count on, for example, being able to reliably find the path to the file that contains the definition of __main__. That's a weakness, IMO.

Re: Why doesn't Python remember the initial directory?

2012-08-20 Thread Steven D'Aprano
On Mon, 20 Aug 2012 12:56:42 +0100, andrea crotti wrote: In the specific case there is absolutely no use of os.chdir, since you can: - use absolute paths - things like subprocess.Popen accept a cwd argument - at worst you can chdir back to the previous position right after the broken thing

Re: Why doesn't Python remember the initial directory?

2012-08-20 Thread Walter Hurry
On Mon, 20 Aug 2012 13:14:02 +, Steven D'Aprano wrote: On Mon, 20 Aug 2012 12:56:42 +0100, andrea crotti wrote: In the specific case there is absolutely no use of os.chdir, since you can: - use absolute paths - things like subprocess.Popen accept a cwd argument - at worst you can chdir

Re: Why doesn't Python remember the initial directory?

2012-08-20 Thread Roy Smith
In article k0tf8g$adc$1...@news.albasani.net, Walter Hurry walterhu...@lavabit.com wrote: It is difficult to think of a sensible use for os.chdir, IMHO. It is true that you can mostly avoid chdir() by building absolute pathnames, but it's often more convenient to just cd somewhere and use

Re: Why doesn't Python remember the initial directory?

2012-08-20 Thread andrea crotti
2012/8/20 Roy Smith r...@panix.com: In article k0tf8g$adc$1...@news.albasani.net, Walter Hurry walterhu...@lavabit.com wrote: It is difficult to think of a sensible use for os.chdir, IMHO. It is true that you can mostly avoid chdir() by building absolute pathnames, but it's often more

Re: Why doesn't Python remember the initial directory?

2012-08-20 Thread Jean-Michel Pichavant
kj wrote: 99.99% of Python programmers will find that there's nothing wrong with behavior [snip] Pardon my cynicism, but the general vibe from the replies I've gotten to my post (i.e. if Python ain't got it, it means you don't need it) [snip] Don't you find there's something wrong in

Re: Why doesn't Python remember the initial directory?

2012-08-20 Thread Grant Edwards
On 2012-08-20, kj no.em...@please.post wrote: In roy-ca6d77.17031119082...@news.panix.com Roy Smith r...@panix.com writes: In article k0rj38$2gc$1...@reader1.panix.com, kj no.em...@please.post wrote: As far as I've been able to determine, Python does not remember (immutably, that is) the

Re: Why doesn't Python remember the initial directory?

2012-08-20 Thread Piet van Oostrum
kj no.em...@please.post writes: This means that no library code can ever count on, for example, being able to reliably find the path to the file that contains the definition of __main__. That's a weakness, IMO. On Unix based systems there is no reliable way to find out this information. So

Re: Why doesn't Python remember the initial directory?

2012-08-20 Thread Neil Hodgson
Nobody: Maybe. On Unix, it's possible that the current directory no longer has a pathname. Its also possible that you do not have permission to successfully call getcwd. One example of this I have experienced is the OS X sandbox where you can run Python starting in a directory where you

Re: Why doesn't Python remember the initial directory?

2012-08-20 Thread Paul Rubin
alex23 wuwe...@gmail.com writes: Oh my god, how DARE people with EXPERIENCE in a language challenge the PRECONCEPTIONS of an AMATEUR!!! HOW DARE THEY?!?! +1 QOTW :) -- http://mail.python.org/mailman/listinfo/python-list

Why doesn't Python remember the initial directory?

2012-08-19 Thread kj
As far as I've been able to determine, Python does not remember (immutably, that is) the working directory at the program's start-up, or, if it does, it does not officially expose this information. Does anyone know why this is? Is there a PEP stating the rationale for it? Thanks! --

Re: Why doesn't Python remember the initial directory?

2012-08-19 Thread Giacomo Alzetta
Il giorno domenica 19 agosto 2012 22:42:16 UTC+2, kj ha scritto: As far as I've been able to determine, Python does not remember (immutably, that is) the working directory at the program's start-up, or, if it does, it does not officially expose this information. Does anyone know why

Re: Why doesn't Python remember the initial directory?

2012-08-19 Thread Roy Smith
In article k0rj38$2gc$1...@reader1.panix.com, kj no.em...@please.post wrote: As far as I've been able to determine, Python does not remember (immutably, that is) the working directory at the program's start-up, or, if it does, it does not officially expose this information. Why would you

Re: Why doesn't Python remember the initial directory?

2012-08-19 Thread Mark Lawrence
On 19/08/2012 21:42, kj wrote: As far as I've been able to determine, Python does not remember (immutably, that is) the working directory at the program's start-up, or, if it does, it does not officially expose this information. Does anyone know why this is? Is there a PEP stating the

Re: Why doesn't Python remember the initial directory?

2012-08-19 Thread Laszlo Nagy
On 2012-08-19 22:42, kj wrote: As far as I've been able to determine, Python does not remember (immutably, that is) the working directory at the program's start-up, or, if it does, it does not officially expose this information. Does anyone know why this is? Is there a PEP stating the

Re: Why doesn't Python remember the initial directory?

2012-08-19 Thread Nobody
On Sun, 19 Aug 2012 14:01:15 -0700, Giacomo Alzetta wrote: You can obtain the working directory with os.getcwd(). Maybe. On Unix, it's possible that the current directory no longer has a pathname. As with files, directories can be deleted (i.e. unlinked) even while they're still in use.

Re: Why doesn't Python remember the initial directory?

2012-08-19 Thread 88888 Dihedral
On Monday, August 20, 2012 4:42:16 AM UTC+8, kj wrote: As far as I've been able to determine, Python does not remember (immutably, that is) the working directory at the program's start-up, or, if it does, it does not officially expose this information. Does anyone know why this is?

Re: Why doesn't Python remember the initial directory?

2012-08-19 Thread kj
In roy-ca6d77.17031119082...@news.panix.com Roy Smith r...@panix.com writes: In article k0rj38$2gc$1...@reader1.panix.com, kj no.em...@please.post wrote: As far as I've been able to determine, Python does not remember (immutably, that is) the working directory at the program's start-up, or,

Re: Why doesn't Python remember the initial directory?

2012-08-19 Thread Jerry Hill
On Sun, Aug 19, 2012 at 9:57 PM, kj no.em...@please.post wrote: By now I have learned to expect that 99.99% of Python programmers will find that there's nothing wrong with behavior like the one described above, that it is in fact exactly As It Should Be, because, you see, since Python is the

Re: Why doesn't Python remember the initial directory?

2012-08-19 Thread alex23
On Monday, 20 August 2012 11:57:46 UTC+10, kj wrote: This means that no library code can ever count on, for example, being able to reliably find the path to the file that contains the definition of __main__. That's a weakness, IMO. No, it's not. It's a _strength_. If you've written a

Re: Why doesn't Python remember the initial directory?

2012-08-19 Thread alex23
My apologies for any double-ups and bad formatting. The new Google Groups interface seems to have effectively shat away decades of UX for something that I can only guess was generated randomly. -- http://mail.python.org/mailman/listinfo/python-list

Re: Why doesn't Python remember the initial directory?

2012-08-19 Thread alex23
On Monday, 20 August 2012 12:57:44 UTC+10, alex23 wrote: a library that requires absolute knowledge of its installed location in order for its internals to work That should read: a library that requires derivation of its installed location from the current working directory in order etc --

Re: Why doesn't Python remember the initial directory?

2012-08-19 Thread Steven D'Aprano
On Mon, 20 Aug 2012 01:57:46 +, kj wrote: In roy-ca6d77.17031119082...@news.panix.com Roy Smith r...@panix.com writes: In article k0rj38$2gc$1...@reader1.panix.com, kj no.em...@please.post wrote: As far as I've been able to determine, Python does not remember (immutably, that is) the

Re: Why doesn't Python remember the initial directory?

2012-08-19 Thread alex23
On Monday, 20 August 2012 13:38:03 UTC+10, Steven D'Aprano wrote: Not so much. More of, yes, that's a bug, but it's not an important bug. If you have a patch for fixing it, we'll consider it, but if you don't, we've got about two thousand more important bugs and features to get through

Re: Why doesn't Python remember the initial directory?

2012-08-19 Thread alex23
On Monday, 20 August 2012 12:57:44 UTC+10, alex23 wrote: If you've written a library that requires absolute knowledge of its installed location in order for its internals to work, then I'm not installing your library. That should read: requires the ability to derive absolute knowledge of