Python Forum
Class construction in python
Thread Rating:
  • 2 Vote(s) - 2.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Class construction in python
#2
This call here is the problem:

meanx = Correlation.Mean1(self.a)
By referencing the class (Correlation) rather than the instance (self), you are calling an unbound method. But the Mean1 method is written as a bound method, which you would normally call by referencing self. You are then providing a parameter to the call. Since you have called it unbound, it is not providing the automatic self parameter, the parameter you provide (self.a) becomes the self parameter within the method call. Since self.a is a list, you getting the error you saw.

You want to call it as a bound parameter:

meanx = self.Mean1()
That will provide the automatic parameter self (equal to the instance) to the method, and self.a will resolve correctly. You would need to adjust your other calls using Correlation similarly.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
Class construction in python - by Alberto - Jul-18-2017, 01:13 PM
RE: Class construction in python - by ichabod801 - Jul-18-2017, 02:25 PM
RE: Class construction in python - by Alberto - Jul-18-2017, 02:39 PM
RE: Class construction in python - by ichabod801 - Jul-18-2017, 03:37 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Total electric construction cost project SecondSandwich94 2 2,271 Jul-21-2021, 09:37 PM
Last Post: deanhystad
  I'm blocked in the construction of my program [Novice] abcd 1 2,696 May-22-2018, 06:02 AM
Last Post: buran
  Converting c++ class to python class panoss 12 12,104 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