softpano / pythonizer

Translator (or more correctly transcriber) from Perl to Python
http://www.softpanorama.org/Scripting/Pythonorama/Python_for_perl_programmers/Pythonizer/index.shtml
Other
39 stars 17 forks source link

Perl ? : operator generates bad code #52

Open snoopyjc opened 2 years ago

snoopyjc commented 2 years ago

Perl ? : operator generates bad code if the first part is not parenthesized, or if it's not directly used in an assignment statement. For example:

$redirect = $options{debug} ? "2>&1" : "2>&1 >/dev/null";

Generates:

redirect='2>&1' if ['debug' else '2>&1 >/dev/null'
snoopyjc commented 2 years ago

Fixed in https://github.com/snoopyjc/pythonizer