tuple versus list
Bryan
belred at gmail.com
Sun Oct 16 16:04:48 EDT 2005
bonono at gmail.com wrote:
> In this particular case, it seems that (width,height) looks nicer. But
> I think otherwise, list constuct is easier to read, even though it is
> supposed to be slower.
>
> With list you can :
> [a] + [ x for x in something ]
>
> With tuple it looks like this :
> (a,) + tuple(x for x in something)
>
> I think the list looks cleaner. And since you cannot concat tuple with
> list, I think unless it looks obvious and natural(as in your case), use
> list.
>
i always use the structure analogy. if you view (width, height) as a structure,
use a tuple. if you view it a sequence, use a list. in this example, i view it
as a stucture, so i would use (width, height) as a tuple.
bryan
More information about the Python-list
mailing list