what's the command for (cd ..) in python
cs at zip.com.au
Sat Sep 10 19:50:46 EDT 2011
On 10Sep2011 15:57, Waldek M. <wm at localhost.localdomain> wrote:
| On Sat, 10 Sep 2011 21:11:32 +1000, Steven D'Aprano wrote:
| > The main one that comes to mind is os.walk, which has this to say:
| > Caution: if you pass a relative pathname for top, don't change the
| > current working directory between resumptions of walk. walk never
| > changes the current directory, and assumes that the client doesn't
| > either.
| > Seems like a reasonable assumption to me.
| Oh, that kind of functions.
| Yes, that *is* surely reasonable, just as mixing chdir/mkdir/remove
| and whatever else that affects the directory structure is not a good idea,
| or at least something to be done carefully.
| I just wouldn't think to give it some special credit.
It's like umask and friends - they affect a program-wide implicit state.
Umask affects default new file permissions, chdir affects starting point
for relative pathnames, etc. All implicit.
The usual biggie with chdir is that of course your program may have been
handed relative file pathnames on the command line. They need resolving
_before_ any chdiring happens, if chdiring is going to happen.
For this kind of reason chdir, umask et al are generally best used in
top level logic only rather than inside library functions.
Cameron Simpson <cs at zip.com.au> DoD#743
It's hard to believe that something as rational as the metric system was
invented by the French. - Henry O. Farad <lrc at netcom.COM>
More information about the Python-list