Re: "0 in [True,False]" returns True
Thanks for the link Carsten, the explanation is clear I didn't know where to search in the Python documentation, there isn't a section about keywords (always wondered why without daring to say - now it's done). So I typed ' "in" operator Python ' in Google, which gave : - on the first page a link to AM Kuchling's and Moshe Zadka's "What's new in Python 2.0" which said : "obj in seq returns true if obj is present in the sequence seq; Python computes this by simply trying every index of the sequence until either obj is found or an IndexError is encountered" - on the second page a link to the Python tutorial that says : "The comparison operators in and not in check whether a value occurs (does not occur) in a sequence" I couldn't tell if "present in the sequence" or "obj is found" or "occurs/does not occur in a sequence" meant "is equal to" or "is the same object as". The answer you pointed me to is clear, but for some reason I didn't have the idea of looking in the section "Sequence Types -- str, unicode, list, tuple, buffer, xrange" for the definition of "in" (after all "in" is also used in list comprehensions, generator expressions, exec, etc... and for iteration on iterators) Regards, Pierre -- http://mail.python.org/mailman/listinfo/python-list
Re: "0 in [True,False]" returns True
Ok, I'll explain why I wanted to test if the value was a boolean I have a program that generates HTML tags with attributes. The principle is that TAG('text',arg1=val1,arg2=val2) generates text For HTML attributes that don't have an explicit value (such as the SELECTED attribute in OPTION) the keyword argument to the function must have the value True My program has a class for each tag, all derived from a generic TAG class whose __init__ method takes the arguments : def __init__(self, innerHTML="", **attrs): I have to handle differently the cases where the value is a boolean or another type: - if it's a boolean then if the value is True, generate the argument name ; if the value is False, don't generate anything - if it's not a boolean, generate arg="val". Specifically, it val is 0, generate val = "0" Testing with "if v:" as suggested would fail for val = 0 Anyway, I exposed my silly "if v in [True,False]" just to give my opinion that I found confusing that 0 in [True,False] or (boolean type checking set aside) 0 in [1,range(2),False,'text'] return True Regards, Pierre -- http://mail.python.org/mailman/listinfo/python-list
Re: Web application toolkit recommendation?
You can also take a look at Karrigell (http://karrigell.sourceforge.net). You can write pure Python scripts or use a PHP-like syntax, and it is shipped with gadfly, an SQL engine, and with KirbyBase, a database engine which uses a Pythonic syntax. As for all the web frameworks, you can also work with the APIs available for almost any database under the sun -- http://mail.python.org/mailman/listinfo/python-list