Sanitize Python code and add a 'flags' option