Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #19978
| From | John Gordon <gordon@panix.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Reading files in from the proper directory |
| Date | 2012-02-07 19:46 +0000 |
| Organization | PANIX Public Access Internet and UNIX, NYC |
| Message-ID | <jgrv32$ih7$1@reader1.panix.com> (permalink) |
| References | <f3f576e8-e608-4348-b6ee-fe775d9d1021@x19g2000yqh.googlegroups.com> |
In <f3f576e8-e608-4348-b6ee-fe775d9d1021@x19g2000yqh.googlegroups.com> SMac2347@comcast.net writes:
> Am I correct in thinking that I need to change the current working
> directory to this folder in order for Python to read in these files,
> then generate my output?
You don't have to do it that way, no.
In general, when opening a file, you can do it two ways: Either provide
a full pathname, or provide a relative pathname.
If you provide a full pathname (for example "/usr/home/smith/myfile.txt"),
that file will be opened and it does not matter what the current working
directory is.
If you provide a relative pathname (for example "myfile.txt"), python
will attempt to open that file starting from the current working dir.
--
John Gordon A is for Amy, who fell down the stairs
gordon@panix.com B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Reading files in from the proper directory SMac2347@comcast.net - 2012-02-07 10:14 -0800
Re: Reading files in from the proper directory Dave Angel <d@davea.name> - 2012-02-07 13:40 -0500
Re: Reading files in from the proper directory SMac2347@comcast.net - 2012-02-07 11:03 -0800
Re: Reading files in from the proper directory Peter Otten <__peter__@web.de> - 2012-02-07 19:59 +0100
Re: Reading files in from the proper directory SMac2347@comcast.net - 2012-02-07 11:13 -0800
Re: Reading files in from the proper directory John Gordon <gordon@panix.com> - 2012-02-07 20:00 +0000
Re: Reading files in from the proper directory Peter Otten <__peter__@web.de> - 2012-02-07 21:16 +0100
Re: Reading files in from the proper directory SMac2347@comcast.net - 2012-02-09 12:32 -0800
Re: Reading files in from the proper directory Peter Otten <__peter__@web.de> - 2012-02-09 22:07 +0100
Re: Reading files in from the proper directory Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-02-09 23:05 -0500
Re: Reading files in from the proper directory SMac2347@comcast.net - 2012-02-09 12:36 -0800
Re: Reading files in from the proper directory John Gordon <gordon@panix.com> - 2012-02-07 19:46 +0000
csiph-web