python script and dealing with NULL parameter
I noticed that when the parameter is Null I get a Type Error Unsubscriptable object. Is there a python function or an if statement that will fix this? Thanks, Laura
--On Freitag, 15. Oktober 2004 13:24 Uhr -0500 Laura McCord <Laura.McCord@doucet-austin.com> wrote:
I noticed that when the parameter is Null I get a Type Error Unsubscriptable object. Is there a python function or an if statement that will fix this?
Null? There is no Null parameter or whatever in Zope. You mean None? Please provide a detailed description. Your question makes less sense in the way you have written it.....*and* include a traceback...this should be known requirement for such questions.. Thanks, -aj
Hi, Am Fr, den 15.10.2004 schrieb Laura McCord um 20:24:
I noticed that when the parameter is Null I get a Type Error Unsubscriptable object. Is there a python function or an if statement that will fix this?
There is no "null" in Python. The equivalence to that (and I suspect you are talking about this) is None. Usually database adaptors map SQL "null" to Python None. In python you have: is None ==None to check. In most situations, boolean algebra is more convient: None, "", '', {}, (), [] and so on are logically "false". if maybe_none: will only used if true or not one of the above values also: maybe_none or "defaultvalue" is usefull if you like functional programming (list comprehensions for example) (value is None and "No pricetag") or ("$ %0.2f" % value) would be an expression for full functional programming using boolean algebra :-) (try it out with different values from python command line) Regards Tino
participants (3)
-
Andreas Jung -
Laura McCord -
Tino Wildenhain