> This is my function: > selecteddeptcodes = context.REQUEST.DEPTCODE > currentstatus = context.REQUEST.STATUS > > if currentstatus == 'pending': > for dptcd in selecteddeptcodes: > context.changetolive(DEPTCODE=dptcd) > if currentstatus == 'old': > for dptcd in selecteddeptcodes: > context.changetopending(DEPTCODE=dptcd) > return context.pub_dept_form(context, context.REQUEST, message='Updated > Status') > > The argument in question is selecteddeptcodes.
You can use isinstance or function like that: >>> def list_from_string(s): ... try: ... s + '' ... return [s] ... except: ... return s and then: >>> def f(selecteddeptcodes): ... if selecteddeptcodes is None: return ... selecteddeptcodes = list_from_string(selecteddeptcodes) ... for dptcd in selecteddeptcodes: print dptcd ... >>> f(['aaa', 'bbb']) aaa bbb >>> f(['aaa']) aaa >>> f('aaa') aaa >>> f(None) >>> Regards, Rob -- http://mail.python.org/mailman/listinfo/python-list