Get Bounds

First of all English isn´t my first language, then I´ll try to explain what I’m looking for.
Imagine I have one object that moves around in the stage and when it hit the bounds of the stage, (if it can be done!) it changes it´s position and speed.
I got some results creating objects used as bounds but I´d like to do it through python in the GE for learning purposes.
I know a little about python and have studied some examples but I can´t figure out how to achieve the same results.

Think about some thing like that:

if o.Position()[0] > bounds.right:
o.speedx *= -1

I wold like to know how to get bounds.right that could be one value like 3 or 10 and I don´t know where in the code I need to test these value.

Thanks a lot.

You can’t detect bounds like that. You would need to use getPosition() and compare the position of the object to the position of the bounding object. Positions are measured by the object center. However, there are a few ways you could do what you are asking about.

I think the best way, though, would not even involve positions. Make each wall of the bounds a separate object, then you can use a collision sensor and the getHitObject() method. Then you would know if you had hit the right, left, front or back wall (or you might have more walls than that).