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
38 stars 17 forks source link

Regex's in a list context with groups produces incorrect code #57

Open snoopyjc opened 2 years ago

snoopyjc commented 2 years ago

Regex's in a list context with groups produces incorrect code. For example:

@ymd = $file =~ /^(\d{4})(\d{2})(\d{2})$/; 

Generates:

ymd=(default_match:=re.match('^(\d{4})(\d{2})(\d{2})$',file))

And it should generate:

ymd=(default_match:=re.match('^(\d{4})(\d{2})(\d{2})$',file),default_match.groups() if default_match else [])[1]
snoopyjc commented 2 years ago

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