Importing the SWOL module

Are you looking to use SwolModule to compile your scripts easily ? Well this is the perfect tutorial for you !


logo of SWOL

Step 1: Getting the module

Right now, the only way to get the SWOL module is to download the SWOL repository.
Here, you will find a file called SwolModule.py. This is the module that we're looking for.


Step 2: Importing

Create a new file. Name it however you want.
It's recommended to import SWOL like in the snippet below.
Finally, we want to create an instance of the SWOL object, it's absolutely necessary to do this since the constructor of the SWOL object creates the 3 attributes necessary to compile your SWOL script to python.

from SwolModule import SWOL
swol = SWOL()

Step 3: Compiling

Finally, to compile the swol script. You have to use the compile_to_py() method.
The method will return a string. That is the compiled python code. With that you can (for example) execute it

from SwolModule import SWOL
swol = SWOL()
python_code = swol.compile_to_py("P_(_'Hello, World!'_)_;")
exec(python_code)