[Python-ideas] Reducing language complexity

Chris Angelico rosuav at gmail.com
Wed Dec 25 09:53:14 CET 2013


On Wed, Dec 25, 2013 at 6:47 PM, anatoly techtonik <techtonik at gmail.com> wrote:
> One of the ways to reduce language complexity for new people who read
> you code, is to prepare them for advanced concepts that your code uses
> beforehand. For example, with the following section:
>
> using generators as yield
>
>          ^^^ name of this language feature and also help reference
>                               ^^^ distinct keywords and feature
> markers that you enable

Yes, and it's great that you can choose what the keyword is! We should
announce the usage of this thus:

using using as as
using as as using

and only then use using and as as as and using.

And of course, it's then critical to declare the fact that you're
using built-in functions, in case they confuse people too. And their
parameters might be confusing, too; best to acknowledge the exact
parameter lists that each built-in function uses. Something like this:

using print(*values, sep=' ', end='\n', file=sys.stdout, flush=False)
using open(file, mode='r', buffering=-1, encoding=None,
         errors=None, newline=None, closefd=True, opener=None)

Of course, this could get rather long, so we could break things out
into other files, and put all those 'using' declarations out of the
way. Rather than create new syntax for all this, I recommend we use
specially-formatted comments; that way, older versions of Python won't
be bothered by it. So let's put those two declarations into a file
called stdio.h, and put this at the top of your Python script:

#include <stdio.h>

I'm sure everyone will agree that this is the best thing for Python.

ChrisA


More information about the Python-ideas mailing list