how to conditionally add a dict in-line

Wes James comptekki at gmail.com
Mon Feb 23 23:35:38 EST 2009


I have this line:

navs.append(A(' '+str(i+1)+'
',_href=self.action(args=request.args,vars={'_page':i,'_query':request.vars._query
or ''})))

How do I do something like this:

vars={'_page':i, if request.vars._query not None then insert this
key/value pair ('_query':request.vars._query) else insert nothing }

thx,

-wj



More information about the Python-list mailing list