4v2t
last updated 3 years ago by chrisn #
Wouldn't it be better to just use new-style classes from the start. You tell here that syntax is
class Student:
you might as well tell that it's:
class Student(object):
When people come back to the tutorial if they've forgotten how to create a class, and google sends them to this page, I think it would be better if it's written new-style here.
Comments
"core of all objects" seems like it'd be an incredibly confusing statement or idea for a beginner. By using a new-style class right at the beginning, you suddenly have the user faced with the idea of inheritance, and of the base object type.
And I don't think we're putting a decision into the hands of the user in terms of whether they should use new or old style. I explcitly say in 9.2 that they should use new-style. It's only a problem to a user that decides to stop reading the tutorial right here.
All I wanted to do with this section was introduce the concept and basic use of classes, which is easier when you're not adding new-style into the mix. Note again that in section 9.2, all the classes use new-style, because at that point, the user understands what a class is, and we can begin adding to that.
Baseline 3 years ago #
Don't know if it works or not, but I've altered my alternative intro to mention objects, which would make it easier to write 'class Student(object)' but without having to talk about new-style/old-style.
gerard 3 years ago #

+1 for using new-style classes from the beginning. Starting with tutorial, one presumably do not want to learn old features that are going to be deprecated later. And it is easy to understand that "object" means "the core of all objects". A small notice about old style classes somewhere would be fine. It is important (in a tutorial) to say "prefer this", "do not do this". Beginners (does not matter how experienced in other languages) need to be lead in the best direction. If they have to decide what is better to use on their own, they could be disappointed, misleaded, or simply delayed in the learning. Being a teacher, one have to show the authority to say "this is the best way for you, but not the only one".
pepr 3 years ago #