projects
/
cython.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
merge
[cython.git]
/
tests
/
run
/
if.pyx
1
def f(a, b):
2
"""
3
>>> f(0,0)
4
0
5
>>> f(1,2)
6
2
7
>>> f(1,-1)
8
1
9
"""
10
x = 0
11
if a:
12
x = 1
13
if a+b:
14
x = 2
15
return x
16
17
def g(a, b):
18
"""
19
>>> g(1,2)
20
1
21
>>> g(0,2)
22
2
23
>>> g(0,0)
24
0
25
"""
26
x = 0
27
if a:
28
x = 1
29
elif b:
30
x = 2
31
return x
32
33
def h(a, b):
34
"""
35
>>> h(1,2)
36
1
37
>>> h(0,2)
38
2
39
>>> h(0,0)
40
3
41
"""
42
x = 0
43
if a:
44
x = 1
45
elif b:
46
x = 2
47
else:
48
x = 3
49
return x
50
51
try:
52
import __builtin__ as builtins
53
except ImportError:
54
import builtins
55
56
def i(a, b):
57
"""
58
>>> i(1,2)
59
1
60
>>> i(2,2)
61
2
62
>>> i(2,1)
63
0
64
"""
65
x = 0
66
if builtins.str(a).upper() == u"1":
67
x = 1
68
if builtins.str(a+b).lower() not in (u"1", u"3"):
69
x = 2
70
return x