Naming conventions for python class names (Ex 45)

My question pertains to a comment on Chapter 45 of LP3THW. Under the heading Class Style, one of the bullets says “Always, always have class Name(object) format or else you will be in big trouble.”

I am not entirely sure I understand this statement. Does it recommend that I define classes in the following manner?

class ClassName(object):

That is, to include the ‘object’ part in the definition?

I have looked this up online, and including object (the explicit way) was required in Python 2, and isn’t anymore in python 3. What I am curious about is the ‘big trouble’ part. If I left that bracket empty, would I have anything more to fear than disapproving humans?

In Python 2 you needed the (object) after the name or else you would end up using the subtly buggy and broken version of OOP that Py 2 had.

In python 3 it doesn’t matter, but it seems Python people are still stuck on adding it.

The statement that you’ll be in trouble is more about Python 2 than 3.

And yes, you would CamelCase your name and put (object) after, but in Python 3 you don’t have to add the (object).

1 Like