Python Forum
Defining parent Class in Python 2.7.11
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Defining parent Class in Python 2.7.11
#2
Hi Sarah,

sarah Wrote:Defining parent Class in Python 2.7.11
Don't use python 2.7. Its end of life is scheduled for January 1st, 2020.. Use python 3, otherwise you're going to learn obsolete things and you won't be able to run the code that everybody runs.

sarah Wrote:what is the conventional way to define Parent class is it with () or without ()?

  • In current python 3, the conventional way is without ().
  • In python 2.7, the conventional way is class Test(object): pass
  • The two ways you showed above work in python 2.7 but they define prehistoric "old style classes" that go back to python 1. I'm very nostalgic of python 1 but I wouldn't recommend it to anyone nowadays.
Reply


Messages In This Thread
Defining parent Class in Python 2.7.11 - by sarah - Dec-01-2019, 05:24 PM
RE: Defining parent Class in Python 2.7.11 - by Gribouillis - Dec-01-2019, 08:14 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  dict class override: how access parent values? Andrey 1 1,648 Mar-06-2022, 10:49 PM
Last Post: deanhystad
  Subclass initialized property used in parent class method. Is it bad coding practice? saavedra29 5 1,805 Feb-07-2022, 07:29 PM
Last Post: saavedra29
  Can we access instance variable of parent class in child class using inheritance akdube 3 14,010 Nov-13-2020, 03:43 AM
Last Post: SalsaBeanDip
  Getter/Setter : get parent attribute, but no Getter/Setter in parent nboweb 2 2,995 May-11-2020, 07:22 PM
Last Post: nboweb
  Call a varaible from class in the parent class Clement_2000 1 2,196 May-09-2019, 11:14 PM
Last Post: michalmonday
  parent/add and child/div PyMan 1 2,423 Feb-23-2018, 04:38 PM
Last Post: nilamo
  Converting c++ class to python class panoss 12 11,876 Jul-23-2017, 01:16 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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