Skip to content

Instantly share code, notes, and snippets.

@bmispelon
Created April 27, 2012 15:08
Show Gist options
  • Select an option

  • Save bmispelon/2510022 to your computer and use it in GitHub Desktop.

Select an option

Save bmispelon/2510022 to your computer and use it in GitHub Desktop.
A bit of golfing around empty sets
# 'set'
# can then be used with getattr(__builtins__, XXX)()
# or, even simpler, eval(XXX)()
''.join(help.__doc__[i] for i in [35, 47, 71])
str(bool())[-2:] + str(bool(' '))[0].lower()
(2 * '%s' % tuple(map(bool, range(2)))).lower()[3:6]
''.join(__import__('json').dumps(bool(x)) for x in range(2))[3:6] # not me
# return 5 if passed nothing or a falsish value.
# Return 4 otherwise
reduce(lambda f, g: lambda *args: f(g(*args)), [len, str, bool])()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment