Path: csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; ';-)': 0.03; 'exists.': 0.07; 'granted,': 0.07; 'sys': 0.07; '32-bit': 0.09; 'high-level': 0.09; 'integers': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; '-tkc': 0.16; '64-bit,': 0.16; 'big-endian': 0.16; 'confuse': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'literals': 0.16; 'literals,': 0.16; 'newlines': 0.16; 'portable': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'module': 0.19; 'skip:p 40': 0.19; '>>>': 0.22; 'code,': 0.22; 'import': 0.22; 'aug': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; "i'm": 0.30; 'code': 0.31; 'coded': 0.31; 'ctypes': 0.31; 'decimal': 0.31; 'figure': 0.32; 'supposed': 0.32; 'regular': 0.32; "can't": 0.35; 'convert': 0.35; 'no,': 0.35; '14,': 0.36; 'charset:us-ascii': 0.36; 'should': 0.36; 'pm,': 0.38; 'ensure': 0.60; 'email addr:gmail.com': 0.63; 'to:addr:gmail.com': 0.65; '(here': 0.84; 'received:50.22': 0.84; 'streams': 0.84; '2013,': 0.91; 'directly.': 0.95; '2013': 0.98 Date: Wed, 14 Aug 2013 12:29:56 -0500 From: Tim Chase To: Chris Angelico Subject: Re: .split() Qeustion In-Reply-To: References: <94f8428f-50b9-4ccd-95a0-6eeafda0fe18@googlegroups.com> <1376499950.3355.9802231.6A03F40D@webmail.messagingengine.com> X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - boston.accountservergroup.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tim.thechases.com X-Get-Message-Sender-Via: boston.accountservergroup.com: none Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 41 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1376501324 news.xs4all.nl 15918 [2001:888:2000:d::a6]:34857 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:52527 On 2013-08-14 18:14, Chris Angelico wrote: > On Wed, Aug 14, 2013 at 6:05 PM, wrote: > > On Wed, Aug 14, 2013, at 10:32, wxjmfauth@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. Granted, one might confuse them with regular numeric literals, so it would be best to clarify them by namespace: import sys answer_to_life = sys.platform.integers.42 print(sum(range(sys.platform.integers.0, sys.platform.integers.14))) That way you ensure platform independence, and *much* clearer! ;-) -tkc