Looking at PyHelpers
There is a class called PyPlot
Note, does not work, have to change
Its __init__ constructor
def __init__(self, plotIdx):
to
def __init__(self, iX, iY):
and the declaration in the initization constructor
self.plot = self.map.getPlotByID(plotIdx)
to
self.plot= self.map.plot(iX, iY)
Doing this fixes the fact there is no attribute called getPlotByID
in the class CvMap()
Having, made these changes, if I use somewhere in my code
test = PyPlot(79, 44).getYield()
test now equals the food yield for that plot
However, if I declare in __init__ of my class code
def __init__(self):
.... self.map = CvMap()
.... self.Aplot = self.map.plot(79, 44)
and at some point in my code I write
self.Aplot.getYield(0)
I am back to square one with an python exception error
Yet if I add this to my code
def getFoodYield(self):
.... return self.Aplot.getYield(0)
And then write
test = self.getFoodYield()
no exception it works
What is going on here
There is about python's objects I am not understanding and it is really bugging me
There is a class called PyPlot
Note, does not work, have to change
Its __init__ constructor
def __init__(self, plotIdx):
to
def __init__(self, iX, iY):
and the declaration in the initization constructor
self.plot = self.map.getPlotByID(plotIdx)
to
self.plot= self.map.plot(iX, iY)
Doing this fixes the fact there is no attribute called getPlotByID
in the class CvMap()
Having, made these changes, if I use somewhere in my code
test = PyPlot(79, 44).getYield()
test now equals the food yield for that plot
However, if I declare in __init__ of my class code
def __init__(self):
.... self.map = CvMap()
.... self.Aplot = self.map.plot(79, 44)
and at some point in my code I write
self.Aplot.getYield(0)
I am back to square one with an python exception error
Yet if I add this to my code
def getFoodYield(self):
.... return self.Aplot.getYield(0)
And then write
test = self.getFoodYield()
no exception it works
What is going on here
There is about python's objects I am not understanding and it is really bugging me