#15984: Python 3 preparation: Change some code to use more modern Python idioms
----------------------------+----------------------------
   Reporter:  wluebbe       |            Owner:
       Type:  enhancement   |           Status:  new
   Priority:  major         |        Milestone:  sage-6.2
  Component:  distribution  |         Keywords:  python3
  Merged in:                |          Authors:
  Reviewers:                |  Report Upstream:  N/A
Work issues:                |           Branch:
     Commit:                |     Dependencies:
   Stopgaps:                |
----------------------------+----------------------------
 This fixer changes code like {{{type(x) == T)}}} and {{{while 1:}}} and it
 introduces the {{{sorted()}}} function where appropriate.

 These changes are optional, but they improve style and may provide a small
 performance gain.

 Changes according to {{{lib2to3/fixes/fix_idioms.py}}}:
 {{{
 * Change some type comparisons to isinstance() calls:
     type(x) == T -> isinstance(x, T)
     type(x) is T -> isinstance(x, T)
     type(x) != T -> not isinstance(x, T)
     type(x) is not T -> not isinstance(x, T)

 * Change "while 1:" into "while True:".

 * Change both
     v = list(EXPR)
     v.sort()
     foo(v)

 and the more general
     v = EXPR
     v.sort()
     foo(v)

 into
     v = sorted(EXPR)
     foo(v)
 }}}

--
Ticket URL: <http://trac.sagemath.org/ticket/15984>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to