How would i make this work in python

How would i make a string of cubes go around the circumference of a cylinder parented to another?That is rotating. And then go around the center of the cylinder parented to that cylinder.That is rotating.How could i do that in python?

At the first sight it sounds like you just need to parent the cubes to an empty and rotate the empty. The empty can be parented to the cylinder.

Alternatively, a circle path is: A) go forward B) turn - both at the same time.

A sketch might help to imagine what exactly you want to achieve.

I have found a way to expand space and contract space with gears motors,pulleys and gears.I wanted to make a model of the machine moving in the bge.I am going to try using arrays and cylinders to describe it.I hope it helps you understand.

Here is a picture of what i want it to do.