Python Forum
a Word Inside Parenthesis in Class Decleration
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
a Word Inside Parenthesis in Class Decleration
Hi There;
I am new to python. There is a class definition in python.

class SomeName(object) : """ You usually define data and code here (in the class body). """
What is object in this context?
Object refers to the base object class; it serves as the foundation of all objects in Python. In this particular case, this means that the class SomeName inherits from object - it has all the attributes and methods of object.

As I recall, this is the old syntax. Class definition used to require an explicit inheritance of object. In Python 3, you do not need to explicitly reference object.
You can write
class SomeName:
The class SomeName will be a subclass of 'object' which is the root ancestor of all classes.

In python 2, the explicit reference to 'object' was needed because for backwards compatibility, python 2's class system coexists with an old class system inherited from python 1. So in python 2 there are 'old style classes' (which don't inherit from 'object') and 'new style classes'. Only, the new style classes were new in 2001, but they're no longer new in 2019. In python 3, you can safely ignore the object parent class in the definition.

Possibly Related Threads…
Thread Author Replies Views Last Post
  Practice problem using lambda inside the class jagasrik 3 330 Sep-12-2020, 03:18 PM
Last Post: deanhystad
  How to read file inside class Mekala 11 1,073 May-02-2020, 11:36 AM
Last Post: snippsat
  Python Speech recognition, word by word AceScottie 6 9,259 Apr-12-2020, 09:50 AM
Last Post: vinayakdhage
  Is it mandatory to call superclass init inside the class init? psolar 3 566 Feb-14-2020, 09:16 PM
Last Post: wavic
  print a word after specific word search evilcode1 8 949 Oct-22-2019, 08:08 AM
Last Post: newbieAuggie2019
  parenthesis around a tuple of literals in a for Skaperen 2 545 Aug-25-2019, 03:00 AM
Last Post: Skaperen
  Parenthesis in User-Defined Functions giorgitsu 2 590 Aug-07-2019, 12:56 PM
Last Post: ThomasL
  Get variable from class inside another class hcne 3 920 Mar-30-2019, 03:02 PM
Last Post: ichabod801
  Calling a class inside other class dan789 9 1,153 Jan-06-2019, 02:00 PM
Last Post: dan789
  Escaping whitespace and parenthesis in filenames jehoshua 2 3,556 Mar-21-2018, 09:12 AM
Last Post: jehoshua

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020