Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #8005
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!selfless.tophat.at!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <chris@rebertia.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.023 |
| X-Spam-Evidence | '*H*': 0.95; '*S*': 0.00; 'python': 0.08; 'pm,': 0.10; 'linux': 0.11; 'subject:file': 0.14; 'wrote:': 0.14; '2.6,': 0.16; 'subject:opening': 0.16; 'cc:addr:python-list': 0.17; 'shell': 0.19; 'cheers,': 0.19; 'header:In-Reply-To:1': 0.21; 'cc:2**0': 0.22; 'cc:no real name:2**0': 0.23; 'least,': 0.23; 'oriented': 0.23; "doesn't": 0.25; 'received:209.85.161': 0.26; 'windows': 0.26; 'message-id:@mail.gmail.com': 0.28; 'work:': 0.29; 'cc:addr:python.org': 0.30; 'sun,': 0.30; 'url:library': 0.31; "can't": 0.32; 'chris': 0.34; 'however,': 0.34; 'using': 0.35; 'skip:o 20': 0.37; 'received:google.com': 0.37; 'received:209.85': 0.37; 'url:docs': 0.37; 'url:python': 0.38; 'url:org': 0.38; 'run': 0.38; 'subject:: ': 0.38; 'received:209': 0.39; 'unix': 0.40; 'dennis': 0.77; 'to:addr:yahoo.com': 0.80; 'sender:addr:chris': 0.84; 'url:os': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=aNCphVNT52ynIsYIw5I3CMdXjetTnjOt1KbCc3VPymE=; b=RZqwg15BXb1KK11Q3ALFSChUTX0E2pYV2eAYlOhZExkAKt4n+IUvrSHf1FmA+b4naE KTKMo4+L3LVgEekuEtHDcjUP2BFda8sZ1t7EFZO2NXYL6+Z/defhHmGva2e01Wct8NEj hcOrQEVZIh6Uv77Xw+kKMt+bNezzICKsPtrcI= |
| DomainKey-Signature | a=rsa-sha1; c=nofws; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; b=MMqKAaQmy080iiX6PVHzYeNXcRZ+1F0A0jSq1DV5acFDra2BY4UvYRe38ZicW5Af9M 8kxR1IyMTA+4YIxgSRevh2G+/2Thp71FPEArIJKxcJGxLjdqHsVtSR47xwKDZQcCQOS7 0Jdxg2D+GzFuyPU4MnkxKte+EUQDC5h6TaDfA= |
| MIME-Version | 1.0 |
| Sender | chris@rebertia.com |
| In-Reply-To | <201106192300.38697.tjhanson@yahoo.com> |
| References | <201106192300.38697.tjhanson@yahoo.com> |
| Date | Sun, 19 Jun 2011 23:30:34 -0700 |
| X-Google-Sender-Auth | Lu6WnajG9KPQTL_yK09JZ_2yy1c |
| Subject | Re: opening a file |
| From | Chris Rebert <clp2@rebertia.com> |
| To | Tim Hanson <tjhanson@yahoo.com> |
| Content-Type | text/plain; charset=UTF-8 |
| 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.175.1308551438.1164.python-list@python.org> (permalink) |
| Lines | 20 |
| NNTP-Posting-Host | 82.94.164.166 |
| X-Trace | 1308551438 news.xs4all.nl 49181 [::ffff:82.94.164.166]:36348 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:8005 |
Show key headers only | View raw
On Sun, Jun 19, 2011 at 11:00 PM, Tim Hanson <tjhanson@yahoo.com> wrote:
> Using linux and Python 2.6, learning how to work with files from a Windows
> oriented textbook:
>
> 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?
As Dennis explained, no. At least, not directly. Python doesn't run
filepaths through the shell for expansion.
However, you can use os.path.expanduser() to make ~-paths work:
http://docs.python.org/library/os.path.html#os.path.expanduser
Cheers,
Chris
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: opening a file Chris Rebert <clp2@rebertia.com> - 2011-06-19 23:30 -0700
csiph-web