Opened 6 years ago
Closed 6 years ago
#21983 closed enhancement (fixed)
Remaining py3 syntax level errors
Reported by:  jmantysalo  Owned by:  

Priority:  major  Milestone:  sage7.5 
Component:  python3  Keywords:  
Cc:  chapoton  Merged in:  
Authors:  Jori Mäntysalo  Reviewers:  Frédéric Chapoton 
Report Upstream:  N/A  Work issues:  
Branch:  3cdfd4e (Commits, GitHub, GitLab)  Commit:  3cdfd4e6f7ba5b39f039395dbbc5c9c1f2fe8deb 
Dependencies:  Stopgaps: 
Description
After plain docstring unicode errors (#21982) there are 2 times 2 problems:
lambda (a, b):
syntax atsrc/sage/graphs/generators/smallgraphs.py
andsrc/sage/combinat/matrices/hadamard_matrix.py
. These are easy.
 Some kind of
for i in [1,2], [3,4]
error insrc/sage/combinat/designs/database.py
andsrc/sage/combinat/root_system/coxeter_type.py
. Not sure what to do  Frédéric?
After these we should have empty noerrors
from
find src/sage/ name '*.py'  while read f; do python3 m py_compile $f 2>&1  egrep q . && echo $f >> errors  echo $f >> noerrors ; done
Change History (11)
comment:1 followup: ↓ 2 Changed 6 years ago by
comment:2 in reply to: ↑ 1 Changed 6 years ago by
Replying to jdemeyer:
The syntax
for i in [1,2], [3,4]
is correct in Python 3, so what is the problem?
Something like [f(x) for x in [1, 2], [3, 4]]
I guess. But just run
python3 m py_compile src/sage/combinat/root_system/coxeter_type.py
to see.
comment:3 Changed 6 years ago by
Found it. Actually it just that Python2 allows [x for x in 1, 2, 3]
but Python3 does not. It is explained here: http://pythonhistory.blogspot.fi/2010/06/fromlistcomprehensionstogenerator.html
I can make the patch.
comment:4 Changed 6 years ago by
 Branch set to u/jmantysalo/remaining_py3_syntax_level_errors
comment:5 Changed 6 years ago by
 Commit set to a3af115fed1907a72262b58f68c1eb15170b4688
 Status changed from new to needs_review
New commits:
a3af115  Last py3compliance on syntax level.

comment:6 followup: ↓ 8 Changed 6 years ago by
In hadamard_matrix.py
, it's much better to replace map(lambda x:f(x), I)
by f(x) for x in I
.
comment:7 Changed 6 years ago by
 Commit changed from a3af115fed1907a72262b58f68c1eb15170b4688 to 3cdfd4e6f7ba5b39f039395dbbc5c9c1f2fe8deb
Branch pushed to git repo; I updated commit sha1. New commits:
3cdfd4e  From map() to list comprehension.

comment:8 in reply to: ↑ 6 Changed 6 years ago by
Replying to jdemeyer:
In
hadamard_matrix.py
, it's much better to replacemap(lambda x:f(x), I)
byf(x) for x in I
.
Good point. Maybe I should read the code I am changing. Well, next time then.
comment:9 Changed 6 years ago by
 Reviewers set to Frédéric Chapoton
 Status changed from needs_review to positive_review
ok, good, thanks
comment:10 Changed 6 years ago by
Hooray!
Is there any way to doccheck syntax being py3compliant, i.e. a py2 module to check for py3 syntax?
comment:11 Changed 6 years ago by
 Branch changed from u/jmantysalo/remaining_py3_syntax_level_errors to 3cdfd4e6f7ba5b39f039395dbbc5c9c1f2fe8deb
 Resolution set to fixed
 Status changed from positive_review to closed
The syntax
for i in [1,2], [3,4]
is correct in Python 3, so what is the problem?