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


Groups > comp.lang.python > #46331 > unrolled thread

Re: Python #ifdef

Started byDave Angel <davea@davea.name>
First post2013-05-28 15:57 -0400
Last post2013-05-28 15:57 -0400
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Python #ifdef Dave Angel <davea@davea.name> - 2013-05-28 15:57 -0400

#46331 — Re: Python #ifdef

FromDave Angel <davea@davea.name>
Date2013-05-28 15:57 -0400
SubjectRe: Python #ifdef
Message-ID<mailman.2319.1369771083.3114.python-list@python.org>
On 05/28/2013 03:46 PM, Carlos Nepomuceno wrote:
> Are there Python 'preprocessor directives'?

Python doesn't define a preprocessor, and CPYthon doesn't implement one. 
  Nothing to stop you from doing so, however.
>
> I'd like to have something like '#ifdef' to mix code from Python 2 and 3 in a single file.
>
> Is that possible? How? 		 	   		
>

It's quite possible that you don't need a preprocessor do what you want, 
since Python does much less compile-time checking than C.  Also, it's 
possible to store function objects and module objects in variables, and 
thus to hide many things from the body of the code.

One biggie is print, since that's a reserved word (and a statement) in 
Python 2.x.  But if you're using 2.7 you can use from __future__ import 
print, or something like that, and just use 3.x function semantics.


-- 
DaveA

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web