(very) approximate Perl to Python converter