lambda and if

matt matt at virtualspectator.com
Mon Jun 12 06:46:37 EDT 2000


say you had the following

filenames = map(lambda x:x[2] + "_" + x[0] + "_" + x[1] + ".txt" ,items)

but really wanted
filenames = map(lambda x:x[2] + "_" + x[0] + "_" + (x[1] in ("big",) ? "big" :
"") + ".txt" ,items)

where (x[1] in ('big',) ? "big" : "") is a pseudo c++_pyhton expression that I
want to implement .....

i.e. the result is to append "big" to the filename being created if it is the
2nd element of item, otherwise don't append anything.

regards
Matt




More information about the Python-list mailing list