> But wait a minute, zip isn't just a "callable", it's a class, and adding more methods to it seems perfectly natural, just like lots of other built-in classes.

Zip is a class in CPython 3.8. it may or may not be in other implementations or versions. The API users are currently promised says nothing about it needing to be implemented as a class.

and it was a function in 2.7.

But though Python blurs the lines between various callables and functions, there is a general "sense" of how they are used. And for the most part, zip is not used like a class. WE "use" classes, usually, by creating instances, and then calling various methods on them, etc.

a zip instance on the other hand, returns an iterable, that does not provide any other methods or uses. I have to say, I have not idea why zip is a class rather than a function that returns a zip_iterator instance, but it is certainly an implementation detail.

So while yes, alternate constructors are a common pattern, I don't think they are a common pattern for classes like zip.

That being said, I still like it.


Moreover, even if Python 3.9 decides to make zip() a function instead, that wouldn't prevent the alternate constructors being implemented.
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-leave@python.org
Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/RWE6ZETU3Y6CU43FPAH2MC2KKQCKPH2P/
Code of Conduct: http://python.org/psf/codeofconduct/

Christopher Barker, PhD

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython