Can someone explain this

NusRa

Chieftain
Joined
May 13, 2011
Messages
16
Location
USA
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
 
Thank you the help
The post may have said CvMap
However, I am using CyMap in my code
I know, you can only go by what is written in the forum

Since my last post, things have got much simplier
The issue, as I was seeing it had to do with the meaning of the
Exception that was being thrown
It went like this

Python argument types in
CyPlot.getYield(CyPlot, int)
did not match C++ signature
getYield(class CyPlot(lvalue), enum YieldTypes)

Naturally, when looking at this and pulling what hair I have left out
I focused on that lvalue part, thus explaining my posts of the last 24 hours.
My, error was in the expected value of an enum not the int I was passing.
Lesson learned, I was thinking that by knowing that
YieldTypes.YIELD_FOOD equals 0, I could simply by pass all that and supply
a zero which is an int not an enum which is a list, at its
basic python data structure.
Ugh
 
Back
Top Bottom