Skip to content

Instantly share code, notes, and snippets.

@schmichael
Created July 14, 2012 00:19
Show Gist options
  • Save schmichael/3108419 to your computer and use it in GitHub Desktop.
Save schmichael/3108419 to your computer and use it in GitHub Desktop.
foo = map(lambda s:
# lol my lambda's body is indented
s = s.upper()
print s
return s
, ['does', 'the', 'lambda', 'implicitly', 'end', 'after', 'toplevel', 'returns?'])
@schmichael
Copy link
Author

def _(s):
    s = s.upper()
    print s
    return s
foo = map(_, ['does', 'the', 'lambda', 'implicitly', 'end', 'after', 'toplevel', 'returns?'])

@dcolish
Copy link

dcolish commented Jul 14, 2012

from __future__ import print_function

_ = lambda s: (
    setattr(__builtins__, 'TMP', s.upper()) or
    print(getattr(__builtins__, 'TMP')) or getattr(__builtins__, 'TMP')
)
foo = map(_, ['does', 'the', 'lambda', 'implicitly', 'end', 'after', 'toplevel', 'returns?'])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment