[Python-Dev] Informal educator feedback on PEP 572 (was Re: 2018 Python Language Summit coverage, last part)
chris.barker at noaa.gov
Mon Jul 2 01:59:31 EDT 2018
On Sun, Jul 1, 2018 at 5:25 PM, Steven D'Aprano <steve at pearwood.info> wrote:
> > an optional topic. Once widely used, it ain't optional.
> Without knowing the details of your course, and who they are aimed at,
> we cannot possibly judge this comment. Decorators are widely used, but
> surely you don't teach them in a one day introductory class aimed at
> Here is the syllabus for a ten week course:
That would be mine ;-)
> Note that decorators and even regular expressions don't get touched
> until week ten.
I actually often don't ever get to regex -- why? because they are a topic
all of their own, and not unique to Python. And if code uses a regex, it
doesn't change anything about any other code anywhere. IN sort, regex's are
a library, not a language feature.
Which brings us to decorators (and I'm going to add context managers, as
its similar). Decorators (and even more so context managers) are used
commonly enough that we certainly have to introduce them in a intro class.
But there is a really big distinction between having some idea how to use
them, and knowing how they work / how to write them yourself.
So I introduce:
with open(filename) as the_file:
early on, with only a hand-wavy explanation of what that with is all about.
And when i get to properties, I teach them:
with also a hand-wavy explanation of what that @ symbol is.
and if := catches on, I expect it will be far more common that either of
those, especially in the simple script style codes that newbies are going
to be reading/writing at first.
But in the end, I, at least, am not trying to make the case that assignment
expressions are going to be particularly difficult to understand, but that
they are a significant complication, and any new feature like that makes
the language more complex. That's it.
I taught myself Python with version 1.5 in 1998 -- and have been teaching
it for I think almost ten years. In that time, the language has grown
substantially in complexity, and it does make it harder to teach.
We (UWPCE) recently revamped our 3-class program, and had a lot of debate
about how early to introduce things -- one of the instructors wanted to
leave off lambda and comprehensions 'till the second course in the
sequence, as part of functional programming. I I think he was right, if we
were teaching it in a more isolated environment, but both of those show up
in example code all over the place, so I've found it's necessary to
introduce a lot at a high level early:
*args and **kwargs
(off the top of my head)
So there is basically no way that we won't have to add assignment
expressions early on.
As someone else said: it's another straw on the haystack.
Christopher Barker, Ph.D.
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-Dev