Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
class arguements
#3
in python3 there is no difference. object is base class for all classes and it's not necessary to explicitly inherit from object.
>>> class Foo:
...     pass
... 
>>> type(Foo)
<class 'type'>
>>> class Bar(object):
...     pass
... 
>>> type(Bar)
<class 'type'>
In python2 there are old-style (or classic) class and new-style class. For compatibility reasons, classes are still old-style by default. To be new-style class, it had to inherit from object explicitly.
>>> class Foo:
...     pass
... 
>>> type(Foo)
<type 'classobj'>
>>> class Bar(object):
...     pass
... 
>>> type(Bar)
<type 'type'>
New-style and classic classes

(Apr-29-2020, 10:03 AM)astral_travel Wrote: where the class is given an arguement,

in terms of terminology object is not argument, it's a parent class from which your class inherits. Of course your class can inherits from other custom class, e.g.

class Vehicle:
    pass

class Car(Vehicle):
    pass
But basics of inheritance is explained in the link I shared in the other thread already.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
class arguements - by astral_travel - Apr-29-2020, 10:03 AM
RE: class arguements - by pyzyx3qwerty - Apr-29-2020, 10:19 AM
RE: class arguements - by buran - Apr-29-2020, 10:36 AM
RE: class arguements - by astral_travel - Apr-29-2020, 03:44 PM
RE: class arguements - by deanhystad - Apr-29-2020, 04:04 PM
RE: class arguements - by buran - Apr-29-2020, 04:14 PM
RE: class arguements - by astral_travel - Apr-29-2020, 04:16 PM
RE: class arguements - by buran - Apr-29-2020, 04:30 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Accessing varying command line arguements Rakshan 3 2,135 Jul-28-2021, 03:18 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

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