Mercurial > pub > dyncall > bindings
annotate python/pydc/examples/atoi.py @ 3:f5d4d5c2f750
- gemspec fix
author | cslag |
---|---|
date | Thu, 31 Dec 2015 20:24:53 +0100 |
parents | 0cfcc391201f |
children | bf5625bb6f05 |
rev | line source |
---|---|
0 | 1 from pydc import * |
2 from sys import platform | |
3 | |
4 if platform == "win32": | |
5 libc = load("msvcrt") | |
6 elif platform == "darwin": | |
7 libc = load("/usr/lib/libc.dylib") | |
8 else: | |
9 libc = load("/lib/libc.so.6") | |
10 | |
11 fp_atoi = find(libc,"atoi") | |
12 fp_atof = find(libc,"atof") | |
13 | |
14 def atoi(s): return call(fp_atoi,"p)i",s) | |
15 def atod(s): return call(fp_atof,"p)d",s) | |
16 | |
17 print atoi( "3".join(["12","45"]) ) | |
18 print atod( "3".join(["12","45"]) ) | |
19 |