How to Convert SASS on the fly to CSS in Python?

bottle, css, python, sass

Solution

Thinking about this differently, I thought I could just have my python script run `sass --watch source.sass:target.css` and so I followed up how to run bash commands in python. Hence my `__init_.py` now includes:

bashCommand = "sass --watch ./css/main.sass:./css/main.css"
import subprocess
process = subprocess.Popen(bashCommand.split(), stdout=subprocess.PIPE)

This leads to the `sass` file being automagically converted to `css` without me having to worry about the whole `sass` conversion aspect.

Problem

I come from a PHP-background, more specific Symfony2. Symfony2 has a feature via Assetic to autmagically convert SASS file into CSS. Now I am working on my first python project using the bottle framework, and I am wondering if there exists a likewise way to have an on-the-fly CSS-generation of SASS files. Is there an equivalent to Assetic filters in the python world? Manually running `compass` in the background is not an option. I want to use `SASS`, but the whole ordeal should be very coy on my workflow.

Original source