Proposed new syntax

Chris Angelico rosuav at gmail.com
Thu Aug 17 21:25:58 EDT 2017


On Fri, Aug 18, 2017 at 11:13 AM, Steve D'Aprano
<steve+python at pearwood.info> wrote:
> Within a single language, it is common to have both procedural and declarative
> statements. E.g. in Python for statements are clearly procedural flow control.
> But "import" can be read as a declarative statement:
>
> "Load this module, I don't care how you do it or where you have to search or
> what order you do the searching, so long as you load this module."
>
> Arguably its not *really* declarative, because we can implicitly control the
> search order by manipulating sys.modules and sys.path and a few other ways. But
> that's splitting hairs -- by that standard, SQL SELECT isn't declarative
> either, because databases often give you a way to fine-tune the query plan.

One way to figure out whether it's declarative or imperative is to
consider whether it would be legal for (a) a different Python
implementation, or (b) a different version of the same Python
implementation, to achieve the same goal in a different way. An import
statement is definitely somewhat declarative, because you can
*externally* change the mechanics of the command. (For instance,
activating a virtual environment, or otherwise messing with
PYTHONPATH.)

ChrisA



More information about the Python-list mailing list