[path-PEP] Path inherits from basestring again

Ron Adam rrr at ronadam.com
Wed Jul 27 14:18:07 EDT 2005


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.



More information about the Python-list mailing list