pythonizer icon indicating copy to clipboard operation
pythonizer copied to clipboard

Translator (or more correctly transcriber) from Perl to Python

Results 100 pythonizer issues
Sort by recently updated
recently updated
newest added

Escaped interpolation symbols in "..." generate incorrect python code. Also, symbols `{` and `}` need to be escaped (by doubling them) in python `f"..."` strings. For example: print "three=i\@{3}\$\n"; print...

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} ?...

Hash references should generate a `get()` operation to mimic perl. Currently they give a 'key error' if they key isn't found. Perl returns undef.

Incorrect translation of perl chdir, chmod. For example: chdir $rundir; produces: rundir.os.chdir instead of: os.chdir(rundir)

The -r flag should look for pre_pythonizer in the same dir as pythonizer, not the current dir

Array assignments to a list of scalars raise exceptions on mismatches. In perl they silently copy over as many elements as they can and fill in the rest with `undef`...

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]

Perl assignments in expressions allows arbitrary LHS, while python only allows a single variable, so things like: if(($year, $month, $day) = @ymd) { ... } or if($arr[0] = $i) {...

The functions ord, chr, print, and say should default to `$_` if no arg is given. For print and say, giving one arg `FH` should also print `$_` when `FH`...

The functions grep and map generate bad code. A lambda function needs to be used, and the BLOCK format puts the array after the right paren.