<div dir="ltr">On Sun, Jul 1, 2018 at 5:25 PM, Steven D'Aprano <span dir="ltr"><<a href="mailto:steve@pearwood.info" target="_blank">steve@pearwood.info</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span><br>
> an optional topic. Once widely used, it ain't optional.<br>
<br>
</span>Without knowing the details of your course, and who they are aimed at, <br>
we cannot possibly judge this comment. Decorators are widely used, but <br>
surely you don't teach them in a one day introductory class aimed at <br>
beginners?<br>
<br>
Here is the syllabus for a ten week course:<br>
<br>
<a href="https://canvas.uw.edu/courses/1026775/pages/python-100-course-syllabus" rel="noreferrer" target="_blank">https://canvas.uw.edu/courses/<wbr>1026775/pages/python-100-cours<wbr>e-syllabus</a><br></blockquote><div><br></div><div>That would be mine ;-)<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Note that decorators and even regular expressions don't get touched <br>
until week ten.</blockquote><div><br></div><div>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.<br><br></div><div>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.<br><br></div><div>So I introduce:<br><br></div><div>with open(filename) as the_file:<br></div><div>    do_somethign_with(the_file)<br><br></div><div>early on, with only a hand-wavy explanation of what that with is all about.<br><br></div><div>And when i get to properties, I teach them:<br><br></div><div>@property<br></div><div>def a_method(self):<br>    ....<br><br></div><div>with also a hand-wavy explanation of what that @ symbol is.<br><br></div><div>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.<br><br></div><div>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.<br><br></div><div>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.<br><br></div><div>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:<br><br></div><div>decorators<br></div><div>comprehensions<br></div><div>lambda<br></div><div>context managers<br></div><div>*args and **kwargs<br></div><div>(off the top of my head)<br></div><div><br></div><div>So there is basically no way that we won't have to add assignment expressions early on.<br> <br></div><div>As someone else said: it's another straw on the haystack.<br></div><div><br></div></div>-CHB<br><br>-- <br><div class="m_8989687998933689409gmail_signature" data-smartmail="gmail_signature"><br>Christopher Barker, Ph.D.<br>Oceanographer<br><br>Emergency Response Division<br>NOAA/NOS/OR&R            (206) 526-6959   voice<br>7600 Sand Point Way NE   (206) 526-6329   fax<br>Seattle, WA  98115       (206) 526-6317   main reception<br><br><a href="mailto:Chris.Barker@noaa.gov" target="_blank">Chris.Barker@noaa.gov</a></div>
</div></div>