Changes between Version 65 and Version 66 of DeveloperGuidelines/Py_2_3


Ignore:
Timestamp:
07/07/19 12:03:17 (6 years ago)
Author:
Dominic König
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DeveloperGuidelines/Py_2_3

    v65 v66  
    268268This may be a temporary issue - web2py's {{{LazyT}}} does not define a {{{__lt__}}} method which is used for sorting in Python-3, but it does define a {{{__cmp__}}} which is used by Python-2.7 and therefore works.
    269269
    270 As a workaround, wrap the {{{lazyT}}} in {{{s3_str}}} when using it as sorting key.
     270For the same reason, sorting an array of {{{lazyT}}} does not work in Python-3.
     271
     272As a workaround, wrap the {{{lazyT}}} in {{{s3_str}}} when sorting or using it as sorting key.
     273
     274{{{#!python
     275a = [T("quick"), T("lazy"), T("fox")]
     276# This will crash with a TypeError in Py3:
     277a.sort()
     278# This will work both in Py2 and Py3:
     279a.sort(key=lambda item: s3_str(item))
     280}}}