I have the following (example) code:
class _1DCoord(): def __init__(self, i): self.i = i def pixels(self): return self.i def tiles(self): return self.i/TILE_WIDTH
I want to do the following:
>>> xcoord = _1DCoord(42) >>> print xcoord 42
But instead, I see this:
>>> xcoord = _1DCoord(42) >>> print xcoord <_1DCoord instance at 0x1e78b00>
I tried using __repr__ as follows:
def __repr__(self): return self.i
But __repr__ can only return a string. Is there a way to do what I'm trying to do, or just refuse to use pixels ()?
source share