Change Layer with Script

I was looking through the docs on python scripting, and had an idea. but to do it, I have to change active layers in a script. but I couldnt find any info on how to do that. So my question is, is this possible, and how?