Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'paths': 0.05; 'say,': 0.05; 'executed': 0.07; 'python': 0.09; 'explanation': 0.09; 'open()': 0.09; 'rules.': 0.09; 'yeah,': 0.09; 'looked': 0.10; 'language': 0.14; '"python': 0.16; '.py': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'means.': 0.16; 'merely': 0.16; 'pathname': 0.16; 'roy': 0.16; 'subject:Discussion': 0.16; 'mon,': 0.16; 'string': 0.17; 'wrote:': 0.17; 'directory.': 0.17; 'passes': 0.17; 'file.': 0.20; 'received:209.85.214.174': 0.21; 'subject:Code': 0.22; 'example': 0.23; 'script': 0.24; 'tried': 0.25; 'header:In-Reply-To:1': 0.25; '(which': 0.26; 'am,': 0.27; 'entries': 0.27; 'message- id:@mail.gmail.com': 0.27; 'this?': 0.28; 'actual': 0.28; 'chris': 0.28; 'run': 0.28; 'implies': 0.29; 'strings,': 0.29; 'subject:some': 0.29; 'though.': 0.29; 'gets': 0.32; 'file': 0.32; 'could': 0.32; 'explains': 0.33; 'to:addr:python-list': 0.33; 'another': 0.33; 'received:google.com': 0.34; 'text': 0.34; 'path': 0.35; 'open': 0.35; 'received:209.85': 0.35; 'ability': 0.36; 'but': 0.36; 'operating': 0.36; 'does': 0.37; 'two': 0.37; 'uses': 0.37; 'quite': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'skip:o 20': 0.38; 'things': 0.38; 'to:addr:python.org': 0.39; 'received:209.85.214': 0.39; 'called': 0.39; 'header:Received:5': 0.40; 'your': 0.60; 'card': 0.62; 'between': 0.63; 'perfect': 0.63; 'jul': 0.65; 'gathering': 0.71; 'smith': 0.71; 'million': 0.72; 'article': 0.78; 'resolution,': 0.84; 'hopes': 0.91; 'from.': 0.93 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 :content-type; bh=UXX4e04p78yHRQbgXnx7xzAGCkDW6G75Uc82f8YkWXc=; b=jsPabm5q3mUqPmPRvtsLXsSOMpOK4GSWAd5yVUocZSVWBUPSx8B6RwYS7VAZTAbOPH yRTQAEJZcm0efPs6njUHW4juuBKTKqHQhn7kCquKefv0DmMDKM/CNTeKlHG7Qd+BnxXH VKLpap5Mbs5Sz4bbscBvR2hivQ0cyuyzphuMbAyeGoSFHugSr76yUjlHRsyisXRiAVHd iQK+DssnSO73Q23s/NWu46iXWbKiS7YtjrESdZQq9l201OD4NXyXLSEgcbwE0ir1t71R dytCxzF2Gz1BHUAvzHtFt1xwDF+n2aEiP0RLpG7njXrW9nvSSGjQVhzWW3i3pYtoAsBR njcQ== MIME-Version: 1.0 In-Reply-To: References: <3c4e2ef9-bf7e-4fbc-bf12-6780fdc3e5d4@googlegroups.com> <09adb3cf-f3f2-4acc-b561-a36dcf15ecc7@googlegroups.com> <11832de7-a064-494e-b3e8-32a2f15a6902@googlegroups.com> Date: Mon, 9 Jul 2012 07:54:47 +1000 Subject: Re: Discussion on some Code Issues From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 35 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1341784495 news.xs4all.nl 6936 [2001:888:2000:d::a6]:48868 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:25056 On Mon, Jul 9, 2012 at 4:17 AM, Roy Smith wrote: > In article , > Chris Angelico wrote: > >> open("doc1.txt","r") >> >> Python will look for a file called doc1.txt in the directory you run >> the script from (which is often going to be the same directory as your >> .py program). > > Well, to pick a nit, the file will be looked for in the current working > directory. This may or may not be the directory you ran your script > from. Your script could have executed chdir() between the time you > started it and you tried to open the file. > > To pick another nit, it's misleading to say, "Python will look for...". > This implies that Python somehow gets involved in pathname resolution, > when it doesn't. Python just passes paths to the operating system as > opaque strings, and the OS does all the magic of figuring out what that > string means. Two perfectly accurate nitpicks. And of course, there's a million and one other things that could happen in between, too, including possibilities of the current directory not even existing and so on. I merely oversimplified in the hopes of giving a one-paragraph explanation of what it means to not put a path name in your open() call :) It's like the difference between reminder text on a Magic: The Gathering card and the actual entries in the Comprehensive Rules. Perfect example is the "Madness" ability - the reminder text explains the ability, but uses language that actually is quite incorrect. It's a better explanation, though. Am I overanalyzing this? Yeah, probably... ChrisA