On Wed, Aug 14, 2013 at 6:29 PM, Tim Chase
<python.l...@tim.thechases.com> wrote:
> On 2013-08-14 18:14, Chris Angelico wrote:
>> On Wed, Aug 14, 2013 at 6:05 PM,  <random...@fastmail.us> wrote:
>> > On Wed, Aug 14, 2013, at 10:32, wxjmfa...@gmail.com wrote:
>> >> I'm always and still be suprised by the number of hard coded
>> >> '\n' one can find in Python code when the portable (here
>> >> win)
>> >>
>> >> >>> os.linesep
>> >> '\r\n'
>> >>
>> >> exists.
>> >
>> > Because high-level code isn't supposed to use the os module
>> > directly. Text-mode streams automatically convert newlines you
>> > write to them.
>>
>> I'm always, and will still be, surprised by the number of hard coded
>> decimal integers one can find in Python code, when the portable way
>> to do it is to use ctypes and figure out whether your literals
>> should be big-endian or little-endian, 32-bit or 64-bit, etc. Yet
>> people continue to just put decimal literals in their code! It
>> can't be portable.
>
> No, no, no...you want
>
>   from sys.platform.integers import 0, 1, 2, 3, 14, 42
>
> to be portable against endian'ness and bit-width.

Oh! I didn't know about sys.platform.integers. All this time I've been
doing it manually, usually copying and pasting a block of integer
definitions from the re module. (I used to copy them from
adamant.princess.ida but some of them were buggy. 2+2 made 5, or 3, or
7, or 25, depending on need.)

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to