123
reputation
1
4

Katriel

SOreadytohelp, apparently :)

class Oops(object):
    def __init__(self):
        Oops.__call__ = self

x = Oops()
x()

> Z = lambda f: (lambda x: f(lambda *args: x(x)(*args)))(lambda x: f(lambda *args: x(x)(*args)))
> fact = Z(lambda f: lambda x: 1 if x == 0 else x * f(x-1))
> fact(5)
... 120

> 0 < 0 == 0
False

def foo():
    return
    yield

raise TypeError() from ValueError()

def spam(*, ham):
    pass

Move code from try to else if you don't want to catch any errors that it produces.

try:
    do_not_do_this_at_home()
except ToldYouSo:
    die()
else:
    whaddyaknow()
finally:
    cleanup()

Yowza!

> class attrdict(dict):
def __init__(self, *args, **kwargs):
  dict.__init__(self, *args, **kwargs)
  self.__dict__ = self

@functools.lru_cache(maxsize=None)
def fib(n):
    if n < 2: return n
    return fib(n-1) + fib(n-2)
0
answers
1
question
~9k
people reached

Top tags (1)

Score 0
Posts 1
Posts % 100

Top posts (1) All Questions Answers | Votes Newest

Badges (5)

Gold

Silver

1

Rarest

Bronze

4

Rarest