How do you swich layer visibility in a game perferably using a python script

The name says it all but i wan’t to do this so i can simply change levels in a game by adding my caracter to all levels and than selecting layers to be visable one at a time.
Thanks

Unfortunately thats not possible.

Try to use scenes instead. Either using the Scene logic bricks or through the python API using the replace method on the scene.

In the BGE the layers are for shading.

Additional the layers split the objects into active and inactive objects.
Active layers = resides in an active Layer. All other are inactive.

As andrew wrote better use scenes for levels.