Greg Ewing wrote: > Jason Orendorff wrote: > > >> A contextmanager is a function that returns a new context manager. >> >>Okay, that last bit is weird. > > > If the name of the decorator is to be 'contextmanager', it > really needs to say something like > > The contextmanager decorator turns a generator into a > function that returns a context manager. > > So maybe the decorator should be called 'contextmanagergenerator'. > Or perhaps not, since that's getting rather too much of an > eyeful to parse...
Strictly speaking this fits in with the existing confusion of "generator factory" and "generator": Py> def g(): ... yield None ... Py> type(g) <type 'function'> Py> type(g()) <type 'generator'> Most people would call "g" a generator, even though its really just a factory function that returns generator objects. So technically, the "contextmanager" decorator turns a generator factory function into a context manager factory function. But its easier to simply say that the decorator turns a generator into a context manager, even if that's technically incorrect. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --------------------------------------------------------------- http://boredomandlaziness.blogspot.com _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com