(An Unofficial) Python Tutorial Wiki

putting the community back in "maintained by the community"

4q5b

I think this is a good, well-written tutorial, but (IMO) it's let down by your use of 'A 3rd Grade CLASS' as an example - the two uses of the word 'Class' are confusing I think, and i can only imagine that this will be the same for the target audience, some of whom may not have English as a first language. Maybe it's possible to cut out some of the 'academic class of students' classes, eg. '... a teacher of the third-grade...' not '...a teacher of a third-grade class'? I think this is a better introduction to classes than the existing one, but the existing one contains a lot of essential stuff too. Perhaps Classes I, Classes II, with your version (Classes I) after Node5-data structures? (Also, I think you should use new-style classes).

Comments

Yeah... I was trying to be funny by calling it "A 3rd Grade CLASS"... Mission failed, I suppose. I have no strong emotional attachment to it, or any other use of the word "class" in that context. I'll change that sometime next week (or of course anyone else is invited to do it for me).

And I'm definitely not advocating that this become the new Classes document, I wrote it to be the new introduction. As Fredrik suggested, it might work if my new stuff was just inserted in front of the current intro. The stuff in the current intro is useful, and should be around somewhere, but a new reader probably shouldn't be assaulted with scopes and namespaces before seeing a single example of a simple class.

Well, it's just IMHO and all - maybe others would disagree. I suppose this is the difficulty of writing or evaluating a tutorial, you're always trying to put yourself in someone else's shoes. I've added an alternative intro anyway, if you'd like to consider it. (it's at the end)

Yeah, I like yours better. Feel free to put it in, I've got to go study!

Oh, and I forgot to mention, I purposely didn't use new-style classes for this introduction, because it means one less thing where we have to say "Trust us, we'll explain it later". Also note that I was the one that changed the current Classes documentation to use all new-style classes, so there is documentation describing one vs. the other.

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.

+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".

"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.

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.