4 ms·
What I never understand about intros like this (even intro courses in college), is why not start with types? Reading the content, it’s obvious there’s something
by AmericanChopper 7y ago
What I never understand about intros like this (even intro courses in college), is why not start with types? Reading the content, it’s obvious there’s something different between a string and a number, and a list (or a dict) is obviously very different again. You quickly figure out that these things are also capable of doing completely different operations, but why? And what things (methods) are they capable of?
I was helping a friend who decided to start a CompSci degree recently (the 101 course was taught in python), and she was massively struggling with type coercion and understanding type methods. Looking at the course forum, so was everybody else. I helped her understand what types were, why they were important and what the built in type methods were (and how to read the python documentation), and it was a major breakthrough for her. She’s now getting close to 100% on her tests.
I was also blown away by how archaic some of the content was, like using .format() instead of fStrings, but that’s a seperate topic.
- webartifex 7y agoI introduce the idea of a type right in chapter 1 because of exactly the argument you make. As Python is really more about the behavior of objects and not so much their type, I introduce these already from chapter 4 onward, for example, iterable vs. container, and many more. I actually would say that this is the essence of any dynamic language (duck typing). "and how to read the python documentation" -> that is an important point you raise!!! I found that beginners have real trouble reading the docs because they are screening for words like "list" instead of "iterable". However, as I teach abstract behaviors early, they actually understand the docs. "like using .format() instead of fStrings" -> I mention .format() but mainly use f-strings and tell the students right away that they are both faster and easier to read and that they should default to them.