Steven D'Aprano wrote:
if some_condition:
flag = True
else:
flag = False
is better written as:
flag = some_condition
Actually, that's a slight over-simplification.
some_condition may not actually be a bool. If you don't mind flag also
being a non-bool, that's fine, but if you want to ensure that it is one
of True/False, then you can call:
flag = bool(some_condition)
to force flag to be one of True or False. But that's generally not
necessary unless you care about what flag looks like when printed.
--
Steven
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor