Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
instance methods invokation
#1
does objects have its methods or invoke them from superclass in python?
for example:
class tst():
    def __init__(self,name,family):
        self.name=name
        self.family=family
        
    def fun(self,a,b):
        print(a+b)


newtst=tst("myname","my family")

tst.fun(newtst,3,5)
newtst.fun(3,5)
in the code above does newtst object invoke fun function from tst class or it has own method and run it directly
and if the latter is true why we need to self parameter in definition class's functions
Reply


Messages In This Thread
instance methods invokation - by mim - Apr-04-2021, 06:26 AM
RE: instance methods invokation - by Gribouillis - Apr-04-2021, 07:05 AM
RE: instance methods invokation - by ibreeden - Apr-04-2021, 07:39 AM
RE: instance methods invokation - by Gribouillis - Apr-04-2021, 08:18 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Bug Copying methods to effect the new owner instead of the old instance Daniel285 2 315 Jun-03-2024, 07:58 AM
Last Post: Gribouillis
  instance methods mim 7 3,443 Mar-28-2021, 03:46 PM
Last Post: deanhystad
  instance methods sharing addresses mim 1 2,376 Mar-28-2021, 05:22 AM
Last Post: deanhystad
  Class object instance. Link instance attribute to class. Can it be done easier. Windspar 7 4,420 Dec-03-2018, 11:16 PM
Last Post: Windspar
  How to check if class instance exists in a list of class instance objects? sonicblind 23 21,302 May-27-2018, 05:44 AM
Last Post: buran
  Python3x running only with one instance (how can I prevent too many running instance) harun2525 5 18,656 Jul-21-2017, 07:36 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

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