[Python-3000] Mini Path object
Talin
talin at acm.org
Mon Nov 6 17:55:46 CET 2006
Josiah Carlson wrote:
> Talin <talin at acm.org> wrote:
>> I'd like to replace this with:
>>
>> .component( slice_object )
>>
>> where the semantics of 'component' are identical to __getitem__ on an
>> array or tuple. So for example:
>>
>> Path( "a", "b" ).component( 0 ) => "a"
>> Path( "a", "b" ).component( 1 ) => "b"
>> Path( "a", "b" ).component( -1 ) => "b"
>> Path( "a", "b" ).component( 0:1 ) => Path( "a", "b" )
>> Path( "a", "b" ).component( 1: ) => Path( "b" )
>
> Use a property or list or something. Something with __getitem__. In
> 2.5 it is a syntax error to use slices like that, and it would seem
> silly to change 3.x syntax to be able to pass slices directly like that.
That's unfortunate. I specifically want to avoid saying something like
path[ 1:2 ], because its ambiguous and confusing, especially if "Path"
is derived from unicode. I suppose path.components[ 1:2 ] would be all
right.
> - Josiah
More information about the Python-3000
mailing list