Re: [path-PEP] Path inherits from basestring again
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

Re: [path-PEP] Path inherits from basestring again

From: Ron Adam <rrr@ronadam.com>
Date: Wed Jul 27 2005 - 20:18:07 CEST

Toby Dickenson wrote:
> On Wednesday 27 July 2005 05:37, Meyer, Tony wrote:
>
>
>>I can see that this would make sense in some situations, but ISTM that it
>>would make a great deal more sense (and be much more intuitive) to have
>>concatenation include the separator character (i.e. be join).
>
>
> def functions_which_modifies_some_file_in_place(path):
> output = open(path+'.tmp', 'w')
> .....
>
> I dont want a seperator inserted between path and the new extension.

My impression of '+', is it always join like objects...

    str+str -> str
    list+list -> list
    tuple+tuple -> tuple

So ...

    path+path -> path

In all current cases, (that I know of), of differing types, '+' raises
an error.

Question: Is a path object mutable?

Would the += operator create an new object or modify the original?

    p = path('C://somedir//somefile')

    p+='.zip' what would this do?

    p[-1]+='.zip' Or this?

Cheer's Ron.
Received on Thu Sep 29 17:11:45 2005