code review

Terry Reedy tjreedy at udel.edu
Sat Jun 30 17:47:55 EDT 2012


On 6/30/2012 5:35 PM, Thomas Jollans wrote:
> 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?

Python pretty consistently evaluates expressions and equal precedence 
operators left to right. One really should learn that. No 
'implementation defined' ambiguity.


-- 
Terry Jan Reedy






More information about the Python-list mailing list