.split() Qeustion
wxjmfauth at gmail.com
wxjmfauth at gmail.com
Thu Aug 15 03:46:14 EDT 2013
Le mercredi 14 août 2013 19:14:59 UTC+2, Chris Angelico a écrit :
> On Wed, Aug 14, 2013 at 6:05 PM, <random832 at fastmail.us> wrote:
>
> > On Wed, Aug 14, 2013, at 10:32, wxjmfauth at 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.
>
>
>
> ChrisA
------
As a stupid scientist, I have the habbit to compare
things of the same nature with the same units.
This *string* containing one *character*
>>> sys.getsizeof('a')
26
consumes 26 *bytes*.
This *string* containing one *character*
>>> sys.getsizeof('\u2023')
40
consumes 40 *bytes*.
and the difference is
40 [bytes] - 26 [bytes] = 14 [bytes] .
—————
Python seems to consider os.linesep as a
str.
>>> isinstance(os.linesep, str)
True
—————
PS A "mole" is not a number.
jmf
More information about the Python-list
mailing list