[Python-ideas] Integrate some itertools into the Python syntax

Andrew Barnert abarnert at yahoo.com
Wed Mar 23 18:38:02 EDT 2016


On Mar 23, 2016, at 15:01, Chris Angelico <rosuav at gmail.com> wrote:
> 
>> On Thu, Mar 24, 2016 at 8:46 AM, Andrew Barnert <abarnert at yahoo.com> wrote:
>> The advantage of having a small set of builtins is that you know the entire
>> set of builtins.
> 
> Python 3.6 has len(dir(builtins))==150, which is hardly small. Even
> removing the ones that don't begin with a lower-case letter (which
> removes a small number of special names like __package__, and a large
> number of exception classes) leaves 72. Can you name them all?

Can you name all 25000 words of English that you know?

There are 68 builtins listed in a nice table at the top of the builtin functions chapter in the docs. Take a look at that table. They're all (except maybe format and iter[1]) functions[2] that you can immediately recognize them when reading them, and recall when they're relevant to code you're writing, including know exactly what their interface is and what they do. If you see "any()" or "int()" in code, you don't need to turn to the docs to look up what it does. If you need to convert something to a debug string representation, you know to call "repr()". The fact that you might leave out "any", "int", or "repr" in a pop quiz demanding that you list all 68 of them in alphabetical order doesn't mean you don't know them.

You certainly can't say the same is true for all functions and methods in the stdlib.

---

[1]: I think everyone knows iter _exists_, but not everyone knows about its two-argument form.

[2]: ... or types...




More information about the Python-ideas mailing list