[Pythonmac-SIG] Please critique my first appscript - a fix for Palm sync of iCal Tasks (for kGTD)
root
Chris.Barker at noaa.gov
Tue Aug 29 19:31:51 CEST 2006
Marcin Komorowski wrote:
> Please kindly critique my code - what could I have done better? What
> would have made this code more Pythonic?
I now nothing of appscript, and didn't even read it all, but a comment
none the less.
> def myDebug( txt ):
> if txt == None:
> sys.stderr.flush()
> else:
> sys.stderr.write( txt )
You should use:
if txt is None:
the equality operator can be overloaded, so you can't count on it for
None. However, you could probably just do:
def myDebug( txt ):
if txt:
sys.stderr.write( txt )
else:
sys.stderr.flush()
that will flush on both None and an empty string (or anything else that
evaluates to False).
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
More information about the Pythonmac-SIG
mailing list