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


Groups > comp.lang.python > #46335

RE: Python #ifdef

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder7.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <bsk16@case.edu>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.025
X-Spam-Evidence '*H*': 0.96; '*S*': 0.01; 'that?': 0.05; 'subject:Python': 0.06; 'received:209.85.219': 0.09; 'runs': 0.10; 'python': 0.11; 'def': 0.12; '2.7': 0.14; "'''": 0.16; 'to:name:python list': 0.16; 'wrote:': 0.18; '&gt;': 0.26; 'header :In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'way?': 0.31; 'run': 0.32; 'received:209.85': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'received:209': 0.37; 'thank': 0.38; 'to:addr :python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'skip:\xc2 10': 0.60; 'skip:n 10': 0.64; '8bit%:100': 0.72; 'subject: #': 0.96; '2013': 0.98
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:x-gm-message-state; bh=huO4TmUU6u48aCX/Smc7TKzbT9ABkXOcV3OUawZBj3U=; b=Kj5HnSPr9fb5PtrsLsZUErecKK6PYO8cnTBRd9fpUsPUGuNEQx6N/uklUwFntdarIu hPLDOl8AFD0Niu11vGB5KgEvQviXpLmrKbY/infu/o5JQblTasOsEGQiUvKz3HyRVtN1 HvEJ7rCfkmTL31ssjKTiwrgPKEObJ6cglId3x9IvQ+c73qxD3BHVPVabdZO6intEKCbT QdUlAOyMH8bpxJoGRQc7mbUji8oHJ0y0rMI+a69PSb6k6YKiR59IdLMj+tdZaufJ9SsS RUSPCSpG+GVjUpxDEpGoy5tuV6lYR9A6ieguKS/Latoqf5RY8+2Hl9a7KCfTyd3QSuFo 0TKA==
X-Received by 10.182.45.231 with SMTP id q7mr22012665obm.58.1369772097879; Tue, 28 May 2013 13:14:57 -0700 (PDT)
MIME-Version 1.0
X-Received by 10.182.45.231 with SMTP id q7mr22012655obm.58.1369772097752; Tue, 28 May 2013 13:14:57 -0700 (PDT)
In-Reply-To <BLU176-W47EB6E75063FE93256EAE8D7970@phx.gbl>
References <BLU176-W12FAFEA3C7AFD687855E04D7970@phx.gbl> <mailman.2318.1369770916.3114.python-list@python.org> <b0kgm4F3gs4U1@mid.individual.net> <BLU176-W47EB6E75063FE93256EAE8D7970@phx.gbl>
Date Tue, 28 May 2013 13:14:57 -0700
Subject RE: Python #ifdef
From Benjamin Kaplan <benjamin.kaplan@case.edu>
To Python List <python-list@python.org>
Content-Type multipart/alternative; boundary=047d7b67785a4faf4f04ddcceb2b
X-Gm-Message-State ALoCoQlFJAP150zDjaUSH78WRv3x94PiA0ICQr/0LcbjqTkSHfkTyKxuYN46AXDgikweOVZXf9cXRnYpJbbMhqz/hRGSWXnBGV9y9UgJohxx3AN/ksz6N1gJZkX5tNEMpKUQKXGMiPIYylMYkUrVPNbNdO4oMfldwA==
X-Junkmail-Whitelist YES (by domain whitelist at mpv2.tis.cwru.edu)
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.2321.1369772484.3114.python-list@python.org> (permalink)
Lines 63
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1369772484 news.xs4all.nl 15973 [2001:888:2000:d::a6]:41734
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:46335

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

On May 28, 2013 1:10 PM, "Carlos Nepomuceno" <carlosnepomuceno@outlook.com>
wrote:
>
> Thank you! I made it run like the following. What do you think about
that? IS there a better way?
>
>
>
> #The following runs on Python 2.7
> sc3='''
> # Python 3
> def original(n):
>     m = 0
>     for b in n.to_bytes(6, 'big'):
>         m = 256*m + b
>     return m
> '''
> if sys.version_info[0] == 3:
>     exec(sc3)
> --

No need for exec.

if sys.version_info[0] >= 3:
    def original(n) :
       ...

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


Thread

Re: Python #ifdef Joel Goldstick <joel.goldstick@gmail.com> - 2013-05-28 15:49 -0400
  Re: Python #ifdef Neil Cerutti <neilc@norwich.edu> - 2013-05-28 20:00 +0000
    RE: Python #ifdef Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-28 23:07 +0300
      Re: Python #ifdef Grant Edwards <invalid@invalid.invalid> - 2013-05-28 20:12 +0000
        RE: Python #ifdef Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-28 23:22 +0300
          Re: Python #ifdef Grant Edwards <invalid@invalid.invalid> - 2013-05-28 20:42 +0000
            RE: Python #ifdef Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-28 23:54 +0300
              Re: Python #ifdef Grant Edwards <invalid@invalid.invalid> - 2013-05-29 14:45 +0000
        RE: Python #ifdef Fábio Santos <fabiosantosart@gmail.com> - 2013-05-28 21:34 +0100
        RE: Python #ifdef Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-28 23:48 +0300
        RE: Python #ifdef Fábio Santos <fabiosantosart@gmail.com> - 2013-05-28 23:51 +0100
    RE: Python #ifdef Benjamin Kaplan <benjamin.kaplan@case.edu> - 2013-05-28 13:14 -0700

csiph-web