![]() |
Available news archives:
comp.lang.tcl
-
comp.lang.python
-
comp.security.firewalls
-
sci.crypt -
comp.lang.php -
comp.lang.javascript
|
|
comp.lang.python archiveRe: [path-PEP] Path inherits from basestring again
From: Ron Adam <rrr@ronadam.com>
Date: Thu Jul 28 2005 - 01:08:38 CEST
Michael Hoffman wrote:
Yes it does, thanks.
In the case of numeric types, it's an addition and not a join. I should
Although it raises other questions... ;-)
Could a string prefix be used with paths as well?
path = p"C://somedir//somefile"
Would that clash with the 'u' prefix? Or would we need a 'p' and a 'up'
You could have both behaviors with the '+'.
path_a + path_b -> join path_b to path_a using separator.
path + string -> append string to path (no separator)
string + path -> prepends string to path (no separator)
This would be similar, (but not exactly like), how u'text'+'text' and
path = path('C:')+path('somedir')+path('somefile.txt')+'.zip'
->> 'C://somedir//somefile.txt.zip'
So I guess the question here is which of these is preferable with '+'?
1. Strings act like paths when one is a path. They will be joined with
2. Paths are joined with separators *and* a string is prepended or
3. All path objects (and strings) act like strings. No separator is
(Seems like #3 defeats the purpose of path a bit to me.)
I'm +1 on #2 after thinking about it.
Cheers,
|