Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #46334
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!news.linkpendium.com!news.linkpendium.com!panix!not-for-mail |
|---|---|
| From | Grant Edwards <invalid@invalid.invalid> |
| Newsgroups | comp.lang.python |
| Subject | Re: Python #ifdef |
| Date | Tue, 28 May 2013 20:12:59 +0000 (UTC) |
| Organization | PANIX Public Access Internet and UNIX, NYC |
| Lines | 34 |
| Message-ID | <ko334b$83c$1@reader1.panix.com> (permalink) |
| References | <BLU176-W12FAFEA3C7AFD687855E04D7970@phx.gbl> <mailman.2318.1369770916.3114.python-list@python.org> <b0kgm4F3gs4U1@mid.individual.net> <mailman.2320.1369771667.3114.python-list@python.org> |
| NNTP-Posting-Host | dsl.comtrol.com |
| X-Trace | reader1.panix.com 1369771979 8300 64.122.56.22 (28 May 2013 20:12:59 GMT) |
| X-Complaints-To | abuse@panix.com |
| NNTP-Posting-Date | Tue, 28 May 2013 20:12:59 +0000 (UTC) |
| User-Agent | slrn/1.0.1 (Linux) |
| Xref | csiph.com comp.lang.python:46334 |
Show key headers only | View raw
On 2013-05-28, 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)
You're trying to make this a lot harder than it really is:
if sys.version_info[0] == 3:
def original(n):
m = 0
for b in n.to_bytes(6, 'big'):
m = 256*m + b
return m
else:
def original(n):
<something else?>
--
Grant Edwards grant.b.edwards Yow! Am I having fun yet?
at
gmail.com
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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