Changes between Version 40 and Version 41 of DeveloperGuidelines/Py_2_3


Ignore:
Timestamp:
07/04/19 19:08:36 (5 years ago)
Author:
Dominic König
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DeveloperGuidelines/Py_2_3

    v40 v41  
    6262
    6363NB the Python-2.7 {{{exec}}} statement also accepts a 3-tuple as parameter {{{exec(expr, globals, locals)}}} which syntax is equivalent to the exec-function in Python-3.
     64
     65=== No cmp-parameter in sorted ===
     66
     67Python-3 does no longer support the {{{cmp}}} parameter for {{{x.sort()}}} and {{{sorted(x)}}}. We use the {{{key}}} parameter instead.
     68
     69For locale-sensitive sorting, use the s3compat alternative {{{sorted_locale}}}:
     70{{{#!python
     71# Python-2 pattern, not working in Python-3:
     72x = sorted(x, cmp=locale.strcoll)
     73# Python-3 pattern, not working with unicode in Python-2:
     74x = sorted(x, key=locale.strxfrm)
     75# Compatible pattern:
     76from s3compat import sorted_locale
     77x = sorted_locale(x)
     78}}}
    6479== Usage ==
    6580