Python #ifdef

Neil Cerutti neilc at norwich.edu
Tue May 28 16:00:04 EDT 2013


On 2013-05-28, Joel Goldstick <joel.goldstick at gmail.com> wrote:
>
> No

Yes. More below.

> On May 28, 2013 3:48 PM, "Carlos Nepomuceno" <carlosnepomuceno at outlook.com>
> wrote:
>> Are there Python 'preprocessor directives'?
>>
>> I'd like to have something like '#ifdef' to mix code from Python 2 and 3
>> in a single file.
>>
>> Is that possible? How?

You need sys.version_info.

For more, see http://python3porting.com/noconv.html

-- 
Neil Cerutti



More information about the Python-list mailing list