Monday, November 10, 2008

Testing form input type in restricted python

My python controller script (.cpy), which should parse input from a form (.cpt), gets a parameter my_param which could be a single string or a list of strings. (If it's a single item, i want it converted to a list, because i'm going to loop over a list of items.)
However, "from types import type, ListType" is not available in a simple script. Luckily, we have something else: same_type

if not same_type(my_param,[]):
my_param = [my_param,]

No comments: