Jason Orendorff wrote: > On 10/12/05, Nick Coghlan <[EMAIL PROTECTED]> wrote: > >>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. > > > Not the same. A precise term exists for "g": it's a generator function. > PEP 255 explicitly talks about this: > > "...Note that when > the intent is clear from context, the unqualified name "generator" may > be used to refer either to a generator-function or a generator- > iterator." > > What would the corresponding paragraph be for PEP 343?
"...Note that when the intent is clear from context, the unqualified name 'context manager' may be used to refer either to a 'context manager function' or to an actual 'context manager object'. This distinction is primarily relevant for generator-based context managers, and is similar to that between a normal generator-function and a generator-iterator." Basically, a context manager object is an object with __enter__ and __exit__ methods, while the __with__ method itself is a context manager function. 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