Coding style

Christophe chris.cavalaria at free.fr
Wed Jul 19 06:26:42 EDT 2006


Patrick Maupin a écrit :
> The perverse wish, expressed in the specific example, that SOME piece
> of code SOMEWHERE should PLEASE throw an exception because some idiot
> passed a generator expression rather than a list into a function, is
> not apt to be well received by an audience which strives for generality
> when it makes sense

Well then, you haven't beed using enouth generator expressions or else, 
that kind of mistake would have bitten you badly by now and you would 
agree with that remark !

> confronted with the wished-for exception, would fix the function so
> that it quite happily accepted generator expressions, rather than
> changing a conditional to use len() just so that an equivalent
> exception could happen a bit earlier.

Thanks but NO. If that function needs to iterate twice on the 
expression, then it needs to iterate twice and passing it a generator 
will only cause strange bugs.



More information about the Python-list mailing list