Pyformlang allows you to manipulate formal languages.
It is fully implemented in python and I tried to make the code clear enough for pedagogical purposes. The code is of course Open Source and can be found on Github. The doc is on
The installation is easy: pip3 install pyformlang.