code review

Thomas Jollans t at jollybox.de
Sat Jun 30 17:35:19 EDT 2012


On 06/30/2012 11:07 PM, Alain Ketterlin wrote:
> Thomas Jollans <t at jollybox.de> writes:
> 
>>>>>> def is_valid_password(password):
>>>>>>     return mud.minpass <= len(password) <= mud.maxpass
> 
>> Which of the two comparisons is done first anyway?
>> "In the face of ambiguity, refuse the temptation to guess."
> 
> There is no ambiguity. See the language reference:

Of course it's technically clearly defined, but the syntax isn't
explicit. To know what the order is (or whether there is an order!) one
has to consult the language reference (which shouldn't be necessary), or
make an educated guess, which would almost certainly be correct, but
we're supposed to refuse the temptation to guess, right?

> "Formally, if a, b, c, ..., y, z are expressions and op1, op2, ..., opN
> are comparison operators, then a op1 b op2 c ... y opN z is equivalent
> to a op1 b and b op2 c and ... y opN z, except that each expression is
> evaluated at most once."
> 
> The last restriction (single evaluation of involved expressions) makes
> this a bit more than raw syntactic sugar.



More information about the Python-list mailing list