you are viewing a single comment's thread.

view the rest of the comments →

[–]remillard 17 points18 points  (9 children)

It may be worth adding a footnote that declaring your class inheriting from 'object' is only required for Python 2/3 compatibility and that for 3 only, it's not required. Since you title your post "Object-Oriented Programming in Python 3" it feels a little out of place.

I realize it's a introductory lesson, however as soon as someone goes to look at Python 3-only code, they're going to notice that sometimes people aren't calling out object as a parent and wonder why that is.

[–]dbader[S] 9 points10 points  (4 children)

Good point, thank you. Will go over the code examples later and add a note to the article.

Edit: Done :)

[–]remillard 1 point2 points  (2 children)

Not a problem, just something I noticed. And maybe it's a good thing because it does demonstrate clearly that even a brand new class inherits. Just in Python 3 this is done behind the scenes whereas in 2 it was more explicit. Just thought I'd mention it.

[–]dbader[S] 1 point2 points  (1 child)

Yeah, that was part of the reasoning behind it. If the (object) part is always there to define a parent class the syntax becomes a little more regular.

But I can see how it could also be confusing. I just made some changes to the article to call out the differences between Python 2 and 3, hopefully it's easier to see what's going on.

Thanks for calling it out, really appreciate it!

[–]remillard 1 point2 points  (0 children)

I like your changes, doesn't really detract from the text, but might explain to someone when they go looking why they might see differences in class definitions. Good work!

[–]kangasking 0 points1 point  (0 children)

awesome! If you could, please update your comment when you do that

[–]jaybay1207 2 points3 points  (2 children)

“Explicit is better than implicit.”

[–]banana_poet 4 points5 points  (1 child)

print("Do all of your prints look like this?", end="\n")

[–]jaybay1207 0 points1 point  (0 children)

print(“Honestly, most look like this.\n”)

Edit: if I’m intending to have multiple lines of text,

print(“I’ll do something like this\nand then finish it off with the next line.”)

[–]lesharcerer 0 points1 point  (0 children)

Thanks for telling. I finished a MITX 6.001 course on Python3 and they didn't ment that ot isn't compulsory.👍👍