"Andy Dingley" <[EMAIL PROTECTED]> writes:
> c_rot13 = lambdaf c : (((c, uc_rot13(c)) [c in
> 'ABCDEFGHIJKLMNOPQRSTUVWXYZ']), lc_rot13(c) )[c in
> 'abcdefghijklmnopqrstuvwxyz']

Oh, I see what you mean, you have separate upper and lower case maps
and you're asking how to select one in an expression.  Pythonistas
seem to prefer using multiple statements:

  def c_rot13(c):
     if c in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ': return uc_rot13(c)
     elif c in 'abcdefghijklmnopqrstuvwxyz': return lc_rot13(c)
     return c

You could use the new ternary expression though:

   c_rot13 = lambda c: \
                  uc_rot13(c) if c in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' else \
                   (lc_rot13(c) if c in 'abcdefghijklmnopqrstuvwxyz' else \
                    c)

if I have that right.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to