Changes between Version 45 and Version 46 of DeveloperGuidelines/Py_2_3


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

--

Legend:

Unmodified
Added
Removed
Modified
  • DeveloperGuidelines/Py_2_3

    v45 v46  
    196196
    197197'''NB''' For building a list from a single iterable argument, we prefer list comprehensions over {{{map()}}} for readability and speed.
     198
     199=== Don't unicode.encode ===
     200
     201Since there is no difference between {{{unicode}}} and {{{str}}}, using the {{{encode()}}} method will produce {{{bytes}}} rather than {{{str}}}.
     202
     203{{{bytes}}} differs from string in that it is an array of integers rather than an array of characters. It will also give a distorted result with any later {{{str()}}} or {{{s3_str()}}}.
     204
     205If you just want to encode a potential {{{unicode}}} instance as an utf-8 encoded {{{str}}}, use {{{s3_str}}} rather than {{{unicode.encode}}}.