raaj
raaj

Reputation: 3311

Python Passing Object to Object

Good Day,

So I have an object called PointArray and another object called Graph. I am passing the object point to Graph as such

class Graph:
    def __init__(self):
        self.pointArray = PointArray()
    description = "This is a class"
    author      = "Raaj"

    def setPointArray(self,pointArray):
        self.pointArray=pointArray

    def plotFFTGraph(self):
        xArr=[]
        yArr=[]
        for point in self.pointArray.freqArray
            xArr.append(point.X)
            yArr.append(point.Y)

        subplot(2,1,2)
        plot(xArr,yArr)

The problem is, Python doesn't seem to recognize that I can access freqArray!

I get this

for point in self.pointArray.freqArray
                                     ^
SyntaxError: invalid syntax

I have imported everything correctly. What gives this error?

Upvotes: 0

Views: 55

Answers (2)

musical_coder
musical_coder

Reputation: 3896

Change it to for point in self.pointArray.freqArray:

Upvotes: 0

Martijn Pieters
Martijn Pieters

Reputation: 1125068

You forgot the colon:

for point in self.pointArray.freqArray:
    #                  ---------------^

Upvotes: 3

Related Questions