Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #7744
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ethan@stoneleaf.us> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'wed,': 0.03; '2.7': 0.04; 'string,': 0.05; 'stuff.': 0.05; 'suppose': 0.05; 'paths': 0.07; 'filename': 0.09; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'hash': 0.09; 'message-id:@stoneleaf.us': 0.09; 'received:gator410.hostgator.com': 0.09; '~ethan~': 0.09; 'programmer': 0.11; 'wrote:': 0.14; "'/'": 0.16; '*must*': 0.16; '3.2,': 0.16; 'ambiguous': 0.16; 'backwards.': 0.16; 'begin?': 0.16; 'disk.': 0.16; 'equal,': 0.16; 'filename,': 0.16; 'furman': 0.16; 'immutable': 0.16; 'item:': 0.16; 'library?': 0.16; 'paths.': 0.16; 'pity': 0.16; 'received:70.85.130': 0.16; 'received:72.11': 0.16; 'received:72.11.125': 0.16; 'received:72.11.125.166': 0.16; 'separator,': 0.16; 'seperate': 0.16; 'sub-class': 0.16; 'then?': 0.16; 'what?': 0.16; 'converting': 0.16; 'header:In-Reply-To:1': 0.21; 'appropriate': 0.21; 'platforms,': 0.23; 'objects': 0.23; 'structure': 0.23; 'compare': 0.26; 'saying': 0.26; 'string': 0.26; 'windows': 0.26; 'object': 0.26; "i'm": 0.27; 'work.': 0.28; 'thanks': 0.28; 'around.': 0.29; 'indicated': 0.29; 'strings.': 0.30; "can't": 0.32; 'yet': 0.32; 'components': 0.32; 'steven': 0.32; 'does': 0.33; 'to:addr:python-list': 0.33; 'too': 0.33; "i've": 0.33; '...': 0.34; "i'll": 0.34; 'however,': 0.34; 'example,': 0.35; 'header:User-Agent:1': 0.35; '-0700,': 0.35; "d'aprano": 0.35; 'replacement': 0.35; 'yet,': 0.35; 'reference': 0.35; 'charset:us- ascii': 0.36; 'thread': 0.37; 'another': 0.37; 'think': 0.38; 'could': 0.38; 'but': 0.38; 'subject:: ': 0.38; 'should': 0.39; "i'd": 0.39; 'either': 0.39; 'add': 0.39; 'to:addr:python.org': 0.39; 'final': 0.60; 'power': 0.61; 'stop': 0.62; 'our': 0.63; 'goals': 0.65; 'direct': 0.65; 'received:websitewelcome.com': 0.67; 'refusing': 0.67; 'care': 0.72; 'dreams': 0.84; 'look,': 0.84; 'self:': 0.84; 'wait,': 0.91 |
| Date | Thu, 16 Jun 2011 09:05:09 -0700 |
| From | Ethan Furman <ethan@stoneleaf.us> |
| User-Agent | Thunderbird 1.5.0.10 (Windows/20070221) |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: os.path and Path |
| References | <mailman.8.1308188800.1164.python-list@python.org> <4df9ad53$0$29973$c3e8da3$5496439d@news.astraweb.com> |
| In-Reply-To | <4df9ad53$0$29973$c3e8da3$5496439d@news.astraweb.com> |
| Content-Type | text/plain; charset=us-ascii; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-AntiAbuse | This header was added to track abuse, please include it with any abuse report |
| X-AntiAbuse | Primary Hostname - gator410.hostgator.com |
| X-AntiAbuse | Original Domain - python.org |
| X-AntiAbuse | Originator/Caller UID/GID - [47 12] / [47 12] |
| X-AntiAbuse | Sender Address Domain - stoneleaf.us |
| X-BWhitelist | no |
| X-Source | |
| X-Source-Args | |
| X-Source-Dir | |
| X-Source-Sender | mail.admailinc.com ([192.168.10.136]) [72.11.125.166]:1091 |
| X-Source-Auth | ethan+stoneleaf.us |
| X-Email-Count | 1 |
| X-Source-Cap | dG9idWs7dG9idWs7Z2F0b3I0MTAuaG9zdGdhdG9yLmNvbQ== |
| 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.16.1308239495.1164.python-list@python.org> (permalink) |
| Lines | 64 |
| NNTP-Posting-Host | 82.94.164.166 |
| X-Trace | 1308239496 news.xs4all.nl 49039 [::ffff:82.94.164.166]:55742 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:7744 |
Show key headers only | View raw
Steven D'Aprano wrote:
> On Wed, 15 Jun 2011 19:00:07 -0700, Ethan Furman wrote:
>
>> Thread 1: "objects of different types compare unequal" self:
>> "nonsense! we have the power to say what happens in __eq__!"
>>
>> Thread 2: "objects that __hash__ the same *must* compare __eq__!" self:
>> "um, what? ... wait, only immutable objects hash..."
>
> Incorrect.
> What you mean to say is that if objects compare equal, they must hash the
> same. Not the other way around.
Ack. I keep saying that backwards. Thanks for the correction.
>> Thread 2: "you're Path object is immutable..." self: "argh!"
>>
>> Here's the rub: I'm on Windows (yes, pity me...) but I prefer the
>> unices, so I'd like to have / seperate my paths. But I'm on Windows...
>
> Any sensible Path object should accept path components in a form
> independent of the path separator, and only care about the separator when
> converting to and from strings.
Our ideas of 'sensible' apparently differ.
One of my goals with my Path objects was to be a drop-in replacement for
the strings currently used as paths; consequently, they are a sub-class
of string, and can still be passed to, for example, os.path.splitext().
Another was to be able to use '/' across all platforms, but still have
the appropriate separator used when the Path object was passed to, for
example, open().
To me, a path is an ambiguous item: /temp/here/xyz.abc
where does the directory structure stop and the filename begin? xyz.abc
could be either the last subdirectory, or the filename, and the only way
to know for sure is to look at the disk. However, the Path may not be
complete yet, or the final item may not exist yet -- so what then? I'm
refusing the temptation to guess. ;) The programmer can explicity look,
or create, appropriately.
> [...]
>> So, I suppose I shall have to let go of my dreams of
>>
>> --> Path('/some/path/and/file') == '\\some\\path\\and\\file'
>
> To say nothing of:
>
> Path('a/b/c/../d') == './a/b/d'
I think I'll make my case-insensitive Paths compare, and hash, as
all-lowercase, so direct string comparison can still work. I'll add an
.eq() method to handle the other fun stuff.
> Why do you think there's no Path object in the standard library? *wink*
Because I can't find one in either 2.7 nor 3.2, and every reference I've
found has indicated that the other Path contenders were too
all-encompassing.
~Ethan~
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
os.path and Path Ethan Furman <ethan@stoneleaf.us> - 2011-06-15 19:00 -0700
Re: os.path and Path Laurent Claessens <moky.math@gmail.com> - 2011-06-16 09:03 +0200
Re: os.path and Path Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-06-16 07:58 +0000
Re: os.path and Path Ethan Furman <ethan@stoneleaf.us> - 2011-06-16 09:16 -0700
Re: os.path and Path Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-06-16 16:41 +0000
Re: os.path and Path Ethan Furman <ethan@stoneleaf.us> - 2011-06-16 10:18 -0700
Re: os.path and Path Eric Snow <ericsnowcurrently@gmail.com> - 2011-06-16 11:21 -0600
Re: os.path and Path Christian Heimes <lists@cheimes.de> - 2011-06-16 18:32 +0200
Re: os.path and Path Ethan Furman <ethan@stoneleaf.us> - 2011-06-16 10:07 -0700
Re: os.path and Path Chris Angelico <rosuav@gmail.com> - 2011-06-17 11:00 +1000
Re: os.path and Path Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-06-16 07:14 +0000
Re: os.path and Path Ethan Furman <ethan@stoneleaf.us> - 2011-06-16 09:05 -0700
Re: os.path and Path Chris Torek <nospam@torek.net> - 2011-06-17 00:48 +0000
Re: os.path and Path Ethan Furman <ethan@stoneleaf.us> - 2011-06-16 18:19 -0700
Re: os.path and Path Ned Deily <nad@acm.org> - 2011-06-16 19:55 -0700
Re: os.path and Path rusi <rustompmody@gmail.com> - 2011-06-16 21:24 -0700
csiph-web