
On Wed, Sep 1, 2021 at 12:22 PM Nick Parlante <nick@cs.stanford.edu> wrote:
Or put another way, None is a pretty core Python topic, so there's no sense in dancing around it too much. Really "is" is the problem.
Indeed, that's quite true. However, while students will see None very early on in their Python experience -- likely from failing to put a return statement in a function definition. But they probably don't need to actually compare to it early in their coding experience. 1. You could use "is", and say "It's most proper to use "is" when comparing
to certain values, including None which we will explain later.
yup -- a fine way to introduce it when you need to -- which again, may not be so early in the class. Interestingly, I find I use "is" far more in class than in real code -- because I use it to talk about the concept of object identity, etc -- that is, David Mertz's example of the difference between: x = y = [] and x, y, = [], [] So yes -- talking about "is: is very closely tied to talking about the concepts of object identity, mutability, all of that. BTW,, I think "is" works best about what you get to lists - so then you
have copies and identity and equality are meaningful, but there's a lot of more basic stuff to get through before you get to lists. Like you don't want to do lists before you have loops and logic.
you don't? the most basic loops in Python are for loops, which loop through an iterable, of which the most common are lists :-) I certainly don't want to teach about the whole iteration protocol before i talk about lists :-) Though yes, you don't need to get into the mutable aspects of lists right off the bat. The is a real chicken and egg challenge with teaching -- but my philosophy is to never demonstrate or teach a "bad practice" as a way to avoid having to talk about a topic early. better to ay (as you suggest above) "trust me on this, it will all make sense later" -CHB PS: Another note: my intro to Python class is an introduction to Python, but NOT an introduction to programming -- we expect our students to have some experience with some programming language. So I do dive into things like object identity pretty early on, as it is something fairly unique to Python. -- Christopher Barker, PhD (Chris) Python Language Consulting - Teaching - Scientific Software Development - Desktop GUI and Web Development - wxPython, numpy, scipy, Cython