and [True,True] --> [True, True]?????

Steven D'Aprano steven at REMOVE.THIS.cybersource.com.au
Mon Apr 20 22:49:02 EDT 2009


On Tue, 21 Apr 2009 00:32:44 +0200, Gerhard Häring wrote:

> The reason I preferred len(), btw., was only that len() make it clear
> that the argument is a sequence.
> 
> Maybe I was just too annoyed by lots of Python code I read that looked
> like this:
> 
> def foo(x, y, z):
>     if x:
>         ...
>     else:
>         ...
> 
> with poorly named variables where I didn't know what the heck the
> variables are (bool, list, instance, ...).


Have you considered that perhaps you don't need to know what the type of 
the variables are? Duck typing and all that.

Besides, if the problem is "poorly named variables", the solution *isn't* 
to call arbitrary functions on them.

len(x) 

x could be a set, a dict, an unsorted list, a sorted list, a tuple, a 
deque, a heap, a binary tree, a graph, a stack, a queue, ... 



-- 
Steven



More information about the Python-list mailing list