Ka/Ks (dN/dS) analysis module for Python?
Do you know about BioPython?

Here, on another website, someone already asked this question and a pretty nice answer was provided by Brad Chapman. He gives already written functions to perform this kind of analysis (I personally haven't tried the codes).

In Perl there is Bio::Align::DNAStatistics. You might adapt it to Python.

This might be useful as well.

I think there are plenty of possibilities that are offered to you. You can go through some others by doing google search with the keywords synonymous, non-synonymous and BioPython.