>From python docs:

For non-negative indices, the length of a slice is the difference of the
indices, if both are within bounds. For example, the length of word[1:3] is
2.

Example:

>>> list_[1][1:3]
('LOOSEFREIGHT', 'MIXEDLCL')
>>>

As I said i think my approach is more pythonic, but I'm not absolutely sure.
With such approach I don't need importing, I use slicing and you are right,
your approach is more flexible and would work on more cases, but in this
particular case I still think unnecessary. Maybe someone else could tell us
which is the best option.

El 30 de marzo de 2011 00:14, Sander Sweers <sander.swe...@gmail.com>escribió:

> 2011/3/29 Rafael Durán Castañeda <rafadurancastan...@gmail.com>:
> > And more pythonic, I think
>
> I don't agree :-). I think itemgetter from the operator module is more
> flexible, readable and elegant than using a lamda. How would you sort
> on the first and last item with lambda?
>
> Greets
> Sander
>
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to