Skip to content

Instantly share code, notes, and snippets.

@Tinche
Created March 21, 2014 00:40
Show Gist options
  • Save Tinche/9677148 to your computer and use it in GitHub Desktop.
Save Tinche/9677148 to your computer and use it in GitHub Desktop.
> cat test.py
from contextlib import contextmanager
@contextmanager
def polite():
print("Hi!")
yield
print("Bye!")
@polite
def fun():
pass
> python3 test.py
Traceback (most recent call last):
File "test.py", line 9, in <module>
@polite
File "/usr/lib/python3.3/contextlib.py", line 115, in helper
return _GeneratorContextManager(func, *args, **kwds)
File "/usr/lib/python3.3/contextlib.py", line 37, in __init__
self.gen = func(*args, **kwds)
TypeError: polite() takes 0 positional arguments but 1 was given
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment