-1

Possible Duplicate:
python class inherits object

In Python 2.7, what is the difference between:

class MyClass(Object):

and

class MyClass:

What does the Object do?

Community
  • 1
  • 1
Eugene
  • 10,957
  • 20
  • 69
  • 97
  • 4
    Is `Object` really capitalized in the place you've seen that sort of code? (If so, it's really bad style, since it can be mistaken for the built in `object` class.) As the answer to the question @jozzas linked says, inheriting (directly or indirectly) from `object` is necessary in Python 2 to get a "new-style" class, rather than a deprecated "old-style" class. – Blckknght Jan 08 '13 at 03:26
  • It was. But in my IDE it prefers object instead of Object. Compared to other languages, the object class is usually capitalized. – Eugene Jan 08 '13 at 03:29

1 Answers1

2

The Object in this case the base class of MyClass, meaning that it 'inherits' the methods and variables of Object unless overwritten. Inheriting from object, however, creates a 'new-style class' as opposed to an 'old-style class'. For more information, see jozzas' comment

See this tutorial for information about inheritance.

Community
  • 1
  • 1
Volatility
  • 31,232
  • 10
  • 80
  • 89