code review

Peter Otten __peter__ at web.de
Sat Jun 30 06:29:31 EDT 2012


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.





More information about the Python-list mailing list