Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #8001 > unrolled thread
| Started by | Florencio Cano <florencio.cano@gmail.com> |
|---|---|
| First post | 2011-06-20 08:14 +0200 |
| Last post | 2011-06-20 12:08 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: opening a file Florencio Cano <florencio.cano@gmail.com> - 2011-06-20 08:14 +0200
Re: opening a file Hans Mulder <hansmu@xs4all.nl> - 2011-06-20 12:08 +0200
| From | Florencio Cano <florencio.cano@gmail.com> |
|---|---|
| Date | 2011-06-20 08:14 +0200 |
| Subject | Re: opening a file |
| Message-ID | <mailman.171.1308550457.1164.python-list@python.org> |
> This works:
> infile=open('/foo/bar/prog/py_modules/this_is_a_test','r')
>
> This doesn't:
> infile=open('~/prog/py_modules/this_is_a_test','r')
>
> Can't I work with files using Unix expressions?
You can use the glob module:
http://docs.python.org/library/glob.html#module-glob
[toc] | [next] | [standalone]
| From | Hans Mulder <hansmu@xs4all.nl> |
|---|---|
| Date | 2011-06-20 12:08 +0200 |
| Message-ID | <4dff1c1e$0$49041$e4fe514c@news.xs4all.nl> |
| In reply to | #8001 |
On 20/06/11 08:14:14, Florencio Cano wrote:
>> This works:
>> infile=open('/foo/bar/prog/py_modules/this_is_a_test','r')
>>
>> This doesn't:
>> infile=open('~/prog/py_modules/this_is_a_test','r')
>>
>> Can't I work with files using Unix expressions?
>
> You can use the glob module:
> http://docs.python.org/library/glob.html#module-glob
The glob module does not do tilde expandsion.
If you want that, you need os.path.expanduser():
http://docs.python.org/library/os.path.html#os.path.expanduser
-- HansM
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web