On Sat, Aug 16, 2008 at 1:22 AM, Joseph Bae <[EMAIL PROTECTED]> wrote:

>             convertTo == "C" and convertToCelsius(temp) or
> convertToFahrenheit(temp)

This idiom has a pitfall. Consider
  A and B or C

If B can evaluate to a false value, such as None or 0, the expression
will not do what you intend. This idiom is only safe when you are sure
that B will never evaluate to false.

In Python 2.5 there is a better way to write it:

  B if A else C

This is a safer way to write your program.

Kent
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to