Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #46346

RE: Python #ifdef

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!newsfeed.fsmpi.rwth-aachen.de!news.unit0.net!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <carlosnepomuceno@outlook.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.008
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'python.': 0.02; 'yet.': 0.04; 'subject:Python': 0.06; 'must.': 0.07; 'developer': 0.10; 'python': 0.11; "wouldn't": 0.14; 'changes': 0.15; '#ifdef': 0.16; 'imposing': 0.16; 'pity': 0.16; 'received:65.55.116.7': 0.16; 'thread,': 0.16; 'module': 0.19; 'to:name:python-list@python.org': 0.22; 'received:65.55.116': 0.24; 'unicode': 0.24; 'script': 0.25; 'header:In-Reply-To:1': 0.27; 'idea': 0.28; 'wonder': 0.29; "doesn't": 0.30; 'especially': 0.30; 'code': 0.31; 'piece': 0.31; 'this.': 0.32; 'run': 0.32; 'call.': 0.33; 'date:': 0.34; 'maybe': 0.34; "can't": 0.35; 'but': 0.35; 'there': 0.35; 'next': 0.36; "didn't": 0.36; 'thanks': 0.36; 'should': 0.36; 'so,': 0.37; 'email addr:python.org': 0.37; 'to:addr:python-list': 0.38; 'short': 0.38; 'skip:_ 30': 0.39; 'does': 0.39; 'subject:': 0.39; 'to:addr:python.org': 0.39; 'email addr:gmail.com': 0.63; 're:': 0.63; 'email name:python-list': 0.65; 'catch?': 0.84; 'joel': 0.91; 'subject: #': 0.96; '2013': 0.98
X-TMN [JCU1fi/qgn7ZigcqVwFGaQtTe2K6JZMw]
X-Originating-Email [carlosnepomuceno@outlook.com]
From Carlos Nepomuceno <carlosnepomuceno@outlook.com>
To "python-list@python.org" <python-list@python.org>
Subject RE: Python #ifdef
Date Wed, 29 May 2013 01:50:35 +0300
Importance Normal
In-Reply-To <CAPM-O+wBX54-K-U=Nkd8rirc3YOMTHcnEfkZAnm=76MdSQ7-gQ@mail.gmail.com>
References <CAPM-O+wBX54-K-U=Nkd8rirc3YOMTHcnEfkZAnm=76MdSQ7-gQ@mail.gmail.com>
Content-Type text/plain; charset="iso-8859-1"
Content-Transfer-Encoding quoted-printable
MIME-Version 1.0
X-OriginalArrivalTime 28 May 2013 22:50:35.0640 (UTC) FILETIME=[C4281780:01CE5BF5]
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2331.1369781444.3114.python-list@python.org> (permalink)
Lines 37
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1369781444 news.xs4all.nl 15888 [2001:888:2000:d::a6]:33645
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:46346

Show key headers only | View raw


________________________________
> Date: Tue, 28 May 2013 18:25:59 -0400 
> Subject: Re: Python #ifdef 
> From: joel.goldstick@gmail.com 
> To: breamoreboy@yahoo.co.uk 
> CC: python-list@python.org 
[...]
>  
> my original response was from cell phone.  I just answered that you  
> can't do ifdefs, implying that there is no preprocessor in python.  I  
> learned a lot of things I didn't know reading the thread, but I wonder  
> if it is a good idea in general to try to write code like this.  --  
> combined 2.x/3.x codebase can be a bear to maintain.  I wouldn't do it  
> unless there was some imposing reason that I must.  Its not just  
> print() -- that isn't bad, but changes in module names (urllib),  
> arithmetic, and unicode especially make this idea in general, very  
> tricky.  Pity the next developer who needs to try to maintain it. 
>  
> So, maybe you CAN do it, but SHOULD you want to do it? 
>  
> --  
> Joel Goldstick 
> http://joelgoldstick.com 


Thanks Joel! In this case I think it does because I would like to have the same short benchmarking script to be runnable by Python 2 and Python 3.

The only piece of code that doesn't run on Python 2 is a to_bytes() single call. So it's not a huge maintenance load. ;)

I didn't try to write 'portable' code to Python 3 yet. What's the catch? 		 	   		  

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

RE: Python #ifdef Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-29 01:50 +0300

csiph-web