code review

Alister alister.ware at ntlworld.com
Sat Jun 30 16:25:39 EDT 2012


On Sat, 30 Jun 2012 12:29:31 +0200, Peter Otten wrote:

> Alister wrote:
> 
>> I think I may be on firmer grounds with the next few:
>> 
>> isValidPassword can be simplified to
>> 
>> def isValidPassword(password:
>>         count=len(password)
>>         return count>= mud.minpass and count<= mud.maxpass
>> 
>> ( I used count to save finding the length of password twice although it
>> probably makes no difference in this scenario)
> 
> If you spell it
> 
> def is_valid_password(password):
>     return mud.minpass <= len(password) <= mud.maxpass
> 
> it is even easier to see that you are performing an interval check.

I realise that was possible, that is brilliant! it is exactly how you 
would write it ass a mathematical definition.




-- 
"The only real way to look younger is not to be born so soon."
		-- Charles Schulz, "Things I've Had to Learn Over and
		   Over and Over"



More information about the Python-list mailing list