Jonathan Bowlas wrote: > Hi Listers, > > I have a requirement to test for a data type could someone tell me if this > is possible in python? > > Basically I have a ZPT in Zope that users can select checkboxes in a form > which pass arguments for a python function, however if there is only one > checkbox selected it is passed as a string whereas more than one checkbox is > passed as a list. >
Fantastic. If there are 0 checkboxes selected, does it return None? The built-in function isinstance() will help. if it is None: shouldbe = [] elif isinstance(it, str): shouldbe = [it] elif isinstance(it, list): shouldbe = it else: raise WTFError(repr(type(it)) Cheers, John -- http://mail.python.org/mailman/listinfo/python-list