Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #46346
| From | Carlos Nepomuceno <carlosnepomuceno@outlook.com> |
|---|---|
| Subject | RE: Python #ifdef |
| Date | 2013-05-29 01:50 +0300 |
| References | <CAPM-O+wBX54-K-U=Nkd8rirc3YOMTHcnEfkZAnm=76MdSQ7-gQ@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2331.1369781444.3114.python-list@python.org> (permalink) |
________________________________ > 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
RE: Python #ifdef Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-29 01:50 +0300
csiph-web