Python #ifdef

Carlos Nepomuceno carlosnepomuceno at outlook.com
Tue May 28 16:07:39 EDT 2013


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) 		 	   		  


More information about the Python-list mailing list