On Mon, Jul 9, 2012 at 4:17 AM, Roy Smith <r...@panix.com> wrote: > In article <mailman.1922.1341767824.4697.python-l...@python.org>, > Chris Angelico <ros...@gmail.com> 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 -- http://mail.python.org/mailman/listinfo/python-list