Python Forum
How to deal with self and __init__ in function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to deal with self and __init__ in function
#1
I am sorry for naive questions, I am new to python.

I am trying to understand how to deal with self when I am trying to understand a function which was written by a third party.
for example:

def __init__(self, peak_finder = None, peak_fitter = None, properties = None, **kwds):
        """
        peak_finder - A PeakFinder object.
        peak_fitter - A PeakFitter object.
        properties - Which properties to return, e.g. "x", "y", etc.
        """
        super(PeakFinderFitter, self).__init__(**kwds)

        self.peak_finder = peak_finder
        self.peak_fitter = peak_fitter
        self.properties = properties

        # The properties must include at least 'x' and 'y'.
        assert ("x" in self.properties), "'x' is a required property."
        assert ("y" in self.properties), "'y' is a required property."
There is awhy to disable self, I guess I can delete all the self words but it seems not the correct way.

In addition,
For few time I have already sow people use __init__, what is the meaning of it, why using it?

Sorry for the naive questions Tongue
Reply


Messages In This Thread
How to deal with self and __init__ in function - by MrFloyd_telomerase - Apr-26-2021, 08:08 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  how to deal with problem of converting string to int usthbstar 1 2,021 Jan-05-2021, 01:33 PM
Last Post: perfringo
  __init__ function arguments CoderMan 4 3,092 Jan-27-2019, 02:04 PM
Last Post: stullis
  How Does pyspark deal with Spaces in Queries cpatte7372 3 2,959 Jul-31-2018, 09:53 PM
Last Post: micseydel
  How to deal with more than 1 input in a line mmaz67 1 2,376 Jul-18-2018, 12:27 PM
Last Post: ichabod801
  Geany frustration how to deal with tabs and spaces and CR mlytle0 2 4,493 Sep-14-2017, 11:51 AM
Last Post: metulburr
  Why is there an __init__ statement within the __init__ definition iFunKtion 7 6,096 Feb-06-2017, 07:31 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