Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #27495
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <andrea.crotti.0@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'value,': 0.03; 'subject:Python': 0.05; '"""': 0.05; 'context': 0.05; 'sysadmin': 0.05; 'type,': 0.07; 'core,': 0.09; 'imho.': 0.09; 'subject:Why': 0.09; 'cc:addr:python-list': 0.10; 'def': 0.10; 'daemons': 0.16; 'dump': 0.16; 'general.': 0.16; 'invoking': 0.16; 'roy': 0.16; 'those,': 0.16; 'wrote:': 0.17; 'directory.': 0.17; 'mostly': 0.20; 'cc:2**0': 0.23; 'programming': 0.23; 'absolute': 0.23; "i've": 0.23; 'somewhere': 0.24; 'cc:no real name:2**0': 0.24; 'command': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply- To:1': 0.25; 'core': 0.27; 'message-id:@mail.gmail.com': 0.27; 'fixed': 0.28; 'run': 0.28; 'sensible': 0.29; 'url:mailman': 0.29; 'skip:_ 10': 0.29; 'source': 0.29; 'class': 0.29; 'that.': 0.30; 'relative': 0.30; 'url:python': 0.32; 'file': 0.32; 'running': 0.32; 'url:listinfo': 0.32; 'goes': 0.33; 'received:google.com': 0.34; 'self': 0.34; 'done': 0.34; 'remote': 0.35; 'sometimes': 0.35; 'subject:?': 0.35; 'received:209.85': 0.35; 'really': 0.36; 'created': 0.36; 'tool': 0.36; 'but': 0.36; 'url:org': 0.36; 'possible': 0.37; 'quite': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'files': 0.38; 'some': 0.38; 'sure': 0.38; 'gives': 0.39; 'header:Received:5': 0.40; 'url:mail': 0.40; 'think': 0.40; 'more': 0.63; 'making': 0.64; 'smith': 0.71; 'article': 0.78; 'designed,': 0.84; 'troubles': 0.84; 'subject:remember': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=nHBaEbE/TDfoRKmfXBaTFhBSiLAsFNWkDR3uAV56er8=; b=Te9DxDs/TjcfcVV5TgN3SmpY+ZapYM15jon4lpxrGF2QeZe+3iZumxY1bgiRVTif4Q 9EPEJz7y/rSIV3o124wkhWztvARA0Ovz+zYmrYfUH1KTqyPUCpjQDJLqmHYSH402hPMt gSLqbnfbD7IlstHD4fNSZo5KdT3ecVY3pAHnydQ4LzPJsJSLsnKQcMdUMnJ+6OJCnrKB xvlFNs6tTe4LifsBcCsS3SDRHvwwZisVD+yuLTbrNR/SEade1b8Pj9mapI9ZDhsZG53R wG4yIosUKsc5rWOMLyf0ODejqjR893Q8eMRoTItQ9HOQL1D0a0jFFnCRmLGQOONRimzk bDtQ== |
| MIME-Version | 1.0 |
| In-Reply-To | <roy-8A3149.09581520082012@news.panix.com> |
| References | <k0rj38$2gc$1@reader1.panix.com> <roy-CA6D77.17031119082012@news.panix.com> <k0s5iq$seh$1@reader1.panix.com> <mailman.3548.1345463804.4697.python-list@python.org> <5032381a$0$29978$c3e8da3$5496439d@news.astraweb.com> <k0tf8g$adc$1@news.albasani.net> <roy-8A3149.09581520082012@news.panix.com> |
| Date | Mon, 20 Aug 2012 15:15:37 +0100 |
| Subject | Re: Why doesn't Python remember the initial directory? |
| From | andrea crotti <andrea.crotti.0@gmail.com> |
| To | Roy Smith <roy@panix.com> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3556.1345472139.4697.python-list@python.org> (permalink) |
| Lines | 51 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1345472139 news.xs4all.nl 6888 [2001:888:2000:d::a6]:39126 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:27495 |
Show key headers only | View raw
2012/8/20 Roy Smith <roy@panix.com>:
> In article <k0tf8g$adc$1@news.albasani.net>,
> Walter Hurry <walterhurry@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
> names relative to that. Fabric (a very cool tool for writing remote
> sysadmin scripts), gives you a cd() command which is a context manager,
> making it extra convenient.
>
> Also, core files get created in the current directory. Sometimes
> daemons will cd to some fixed location to make sure that if they dump
> core, it goes in the right place.
>
> On occasion, you run into (poorly designed, IMHO) utilities which insist
> of reading or writing a file in the current directory. If you're
> invoking one of those, you may have no choice but to chdir() to the
> right place before running them.
> --
> http://mail.python.org/mailman/listinfo/python-list
I've done quite a lot of system programming as well, and changing
directory is only a source of possible troubles in general.
If I really have to for some reasons I do this
class TempCd:
"""Change temporarily the current directory
"""
def __init__(self, newcwd):
self.newcwd = newcwd
self.oldcwd = getcwd()
def __enter__(self):
chdir(self.newcwd)
return self
def __exit__(self, type, value, traceback):
chdir(self.oldcwd)
with TempCd('/tmp'):
# now working in /tmp
# now in the original
So it's not that hard to avoid problems..
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Why doesn't Python remember the initial directory? kj <no.email@please.post> - 2012-08-19 20:42 +0000
Re: Why doesn't Python remember the initial directory? Giacomo Alzetta <giacomo.alzetta@gmail.com> - 2012-08-19 14:01 -0700
Re: Why doesn't Python remember the initial directory? Nobody <nobody@nowhere.com> - 2012-08-20 01:45 +0100
Re: Why doesn't Python remember the initial directory? Neil Hodgson <nhodgson@iinet.net.au> - 2012-08-21 11:39 +1000
Re: Why doesn't Python remember the initial directory? Roy Smith <roy@panix.com> - 2012-08-19 17:03 -0400
Re: Why doesn't Python remember the initial directory? kj <no.email@please.post> - 2012-08-20 01:57 +0000
Re: Why doesn't Python remember the initial directory? Jerry Hill <malaclypse2@gmail.com> - 2012-08-19 22:05 -0400
Re: Why doesn't Python remember the initial directory? alex23 <wuwei23@gmail.com> - 2012-08-19 19:57 -0700
Re: Why doesn't Python remember the initial directory? alex23 <wuwei23@gmail.com> - 2012-08-19 20:04 -0700
Re: Why doesn't Python remember the initial directory? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-20 08:11 +0100
Re: Why doesn't Python remember the initial directory? alex23 <wuwei23@gmail.com> - 2012-08-19 20:03 -0700
Re: Why doesn't Python remember the initial directory? alex23 <wuwei23@gmail.com> - 2012-08-19 19:59 -0700
Re: Why doesn't Python remember the initial directory? Paul Rubin <no.email@nospam.invalid> - 2012-08-20 21:20 -0700
Re: Why doesn't Python remember the initial directory? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-20 03:38 +0000
Re: Why doesn't Python remember the initial directory? alex23 <wuwei23@gmail.com> - 2012-08-19 20:43 -0700
Re: Why doesn't Python remember the initial directory? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-20 08:10 +0100
Re: Why doesn't Python remember the initial directory? andrea crotti <andrea.crotti.0@gmail.com> - 2012-08-20 12:56 +0100
Re: Why doesn't Python remember the initial directory? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-20 13:14 +0000
Re: Why doesn't Python remember the initial directory? Walter Hurry <walterhurry@lavabit.com> - 2012-08-20 13:49 +0000
Re: Why doesn't Python remember the initial directory? Roy Smith <roy@panix.com> - 2012-08-20 09:58 -0400
Re: Why doesn't Python remember the initial directory? andrea crotti <andrea.crotti.0@gmail.com> - 2012-08-20 15:15 +0100
Re: Why doesn't Python remember the initial directory? Jean-Michel Pichavant <jeanmichel@sequans.com> - 2012-08-20 16:39 +0200
Re: Why doesn't Python remember the initial directory? Grant Edwards <invalid@invalid.invalid> - 2012-08-20 16:28 +0000
Re: Why doesn't Python remember the initial directory? Piet van Oostrum <piet@vanoostrum.org> - 2012-08-20 16:06 -0400
Re: Why doesn't Python remember the initial directory? John Roth <johnroth1@gmail.com> - 2012-08-21 13:35 -0700
Re: Why doesn't Python remember the initial directory? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-19 22:18 +0100
Re: Why doesn't Python remember the initial directory? Laszlo Nagy <gandalf@shopzeus.com> - 2012-08-19 23:05 +0200
Re: Why doesn't Python remember the initial directory? 88888 Dihedral <dihedral88888@googlemail.com> - 2012-08-19 17:54 -0700
csiph-web