Skip to content

Instantly share code, notes, and snippets.

@ErinCall
Created September 16, 2012 20:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ErinCall/3734233 to your computer and use it in GitHub Desktop.
Save ErinCall/3734233 to your computer and use it in GitHub Desktop.
>>> def do_something():
... print 'here'
... for x in xrange(0, 8):
... yield x
...
>>> do_something()
<generator object do_something at 0x100428aa0>
>>> foo = do_something()
>>> foo
<generator object do_something at 0x100428b40>
>>> dir(foo)
['__class__', '__delattr__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__iter__', '__name__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'close', 'gi_code', 'gi_frame', 'gi_running', 'next', 'send', 'throw']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment