> >Maybe if you drop support for the "separate protocol" alternative... :-) > > I don't understand you. Are you suggesting a horse trade, or...?
Only tongue-in-cheek. :-) > >I had never heard of that PEP. How much code is there in the field? > > Maybe a dozen or so web applications and frameworks (including Zope, > Quixote, PyBlosxom) and maybe a half dozen servers (incl. Twisted and > mod_python). A lot of the servers are based on my wsgiref library, though, > so it probably wouldn't be too horrible a job to make everybody add > support; I might even be able to fudge wsgiref so that wsgiref-based > servers don't even see an issue. > > Modifying the spec is potentially more controversial, however; it'll have > to go past the Web-SIG, and I assume the first thing that'll be asked is, > "Why aren't generators getting a close() method then?", so I figured I > should ask that question first. > > I'd completely forgotten about this being an issue until Raymond mentioned > g.close(); I'd previously gotten the impression that PEP 325 was expected > to be approved, otherwise I wouldn't have written support for it into PEP 333. > > >Written by whom? > > I used to know who all had written implementations, but there are now too > many to keep track of. Given all that, it's not infeasible to add a close() method to generators as a shortcut for this: def close(self): try: self.__exit__(StopIteration) except StopIteration: break else: # __exit__() didn't raise RuntimeError("or some other exception") I'd like the block statement to be defined exclusively in terms of __exit__() though. -- --Guido van Rossum (home page: http://www.python.org/~guido/) _______________________________________________ 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