[Python-Dev] PEP 572: Assignment Expressions (original) (raw)
Antoine Pitrou solipsis at pitrou.net
Tue Apr 24 06:07:39 EDT 2018
- Previous message (by thread): [Python-Dev] PEP 572: Assignment Expressions
- Next message (by thread): [Python-Dev] PEP 572: Assignment Expressions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Tue, 24 Apr 2018 01:55:13 -0500 Tim Peters <tim.peters at gmail.com> wrote:
[Antoine] > Constructs like "with ..." or "try / except / finally" make the > language easier to learn compared to the dances they are meant to > replace.
They nevertheless need to be taught & learned (and try/except/finally was essentially always in the language), You snipped the parts pointing out that binding expressions are already familiar to people coming from most other languages
Yes... I think most will agree that Python is generally easy to take up for people coming from C++ etc., so my "easier to learn and teach" was mostly about non-programmers.
even for raw beginners the semantics are the tiniest part of what they need to learn anyway about Python's assignment expressions.
I'm not sure what you mean by that. If it's the tiniest part, what's the overwhelming part? Is the new assigment expression that delicate to use that it requires reading a long and intimidating design document ? I didn't get that impression, so it seems you may be making a stronger point than me for rejeting the PEP :-)
> "await" is a more readable and less confusing improvement > over "yield from".
Heh. Not to me. I have literally have no idea what to with "await" (I use generators heavily, but have had no use yet for coroutines), but use yield from aniterable routinely.
Yeah... "yield from" is fine for that, except that it was explicitly meant for the coroutine use case as well (I'm not sure what the timeline is, but probably Guido was already thinking/dreaming about tulip/asyncio back then). And trying to shoehorn both in a single construct made it confusing and inadequate.
When you want to express two abstractly different concepts (generating a stream of values, or suspending a task until some asynchronous subtask finishes), it makes things easier if those two concepts have two different concrete expressions. Hence "await" making the language easier to learn for those whose use cases benefit from it.
To bring another example: the fact that Python has separate syntax to declare classes and functions makes it easier to learn "Python with classes" than "Javascript with classes", even though the raw grammar is made slightly more complex by it. In Javascript you have to learn the weird (ab)use of functional notation for the purpose of declaring object behaviour, and learn to recognize it when you read it. In Python there's the "class" notation which, despite adding a keyword to remember, makes class declaration easier to learn and master.
(^^ note this example is about a potentially obsolete dialect of Javascript; perhaps it has class notation nowadays? ^^)
It's simply impossible that, whatever "await" does, it could be more readable or less confusing than what I use "yield from" for.
Probably because "await" wouldn't work at all for you, then :-)
> Format strings dispense from the older, more convoluted formulations.
But they didn't replace them. That made teaching/learning harder, not easier,
Intuitively, it sounds easier to teach f'some {value}' rather than either the .format() or %-formatting alternatives. The whole goal of f-strings, after all, is to make string formatting more approachable.
Learning a language is not learning the whole spec. When you learn C, you don't need to learn the oddities of pre-ANSI function declarations :-)
However, assignment a special case in this regard, since traditional assignment is so omnipresent in online resources, that people will encounter it even if they make a very focused use of Python.
> Iteration is much simpler than the longer forms we would have to write > if generalized iterators didn't exist.
I'll buy that one. Now go through the HISTORY file and count all the changes you didn't name ;-)
You claimed that """almost no addition has ever made a language easier to learn for raw beginners""". I claim that several additions did (for Python alone), but I don't need to prove that most of them did ;-)
Regards
Antoine.
- Previous message (by thread): [Python-Dev] PEP 572: Assignment Expressions
- Next message (by thread): [Python-Dev] PEP 572: Assignment Expressions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]