comparison python/pydc/examples/atoi.py @ 5:bf5625bb6f05

- brought python binding up to dc v0.9
author cslag
date Tue, 22 Mar 2016 01:49:34 +0100
parents 0cfcc391201f
children edbbd467f50a
comparison
equal deleted inserted replaced
4:4c5019f00f5b 5:bf5625bb6f05
1 from pydc import * 1 from pydc import *
2 from sys import platform 2 import sys
3 import platform
3 4
4 if platform == "win32": 5 if sys.platform == "win32":
5 libc = load("msvcrt") 6 libc = load("msvcrt")
6 elif platform == "darwin": 7 elif sys.platform == "darwin":
7 libc = load("/usr/lib/libc.dylib") 8 libc = load("/usr/lib/libc.dylib")
9 elif "bsd" in sys.platform:
10 libc = load("/usr/lib/libc.so")
11 elif platform.architecture()[0] == "64bit":
12 libc = load("/lib64/libc.so.6")
8 else: 13 else:
9 libc = load("/lib/libc.so.6") 14 libc = load("/lib/libc.so.6")
10 15
11 fp_atoi = find(libc,"atoi") 16 fp_atoi = find(libc,"atoi")
12 fp_atof = find(libc,"atof") 17 fp_atof = find(libc,"atof")
18
19
13 20
14 def atoi(s): return call(fp_atoi,"p)i",s) 21 def atoi(s): return call(fp_atoi,"p)i",s)
15 def atod(s): return call(fp_atof,"p)d",s) 22 def atod(s): return call(fp_atof,"p)d",s)
16 23
17 print atoi( "3".join(["12","45"]) ) 24 print atoi( "3".join(["12","45"]) )