forked from go-python/gopy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
84 lines (67 loc) · 1.82 KB
/
Copy pathtest.py
File metadata and controls
84 lines (67 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# Copyright 2015 The go-python Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
# py2/py3 compat
from __future__ import print_function
import structs
print("s = structs.S()")
s = structs.S()
print("s = %s" % (s,))
print("s.Init()")
s.Init()
print("s.Upper('boo')= %s" % repr(s.Upper("boo")).lstrip('u'))
print("s1 = structs.S1()")
s1 = structs.S1()
print("s1 = %s" % (s1,))
try:
s1 = structs.S1(1)
except Exception as err:
print("caught error: %s" % (err,))
pass
try:
s1 = structs.S1()
print("s1.private = %s" % (s1.private,))
except Exception as err:
print("caught error: %s" % (err,))
pass
print("s2 = structs.S2()")
s2 = structs.S2(1)
print("s2 = %s" % (s2,))
try:
s2 = structs.S2(1, 2)
except Exception as err:
print("caught error: %s" % (err,))
pass
try:
s2 = structs.S2(42)
print("s2 = %s" % (s2,))
print("s2.Public = %s" % (s2.Public,))
print("s2.private = %s" % (s2.private,))
except Exception as err:
print("caught error: %s" % (err,))
pass
class S2Child(structs.S2):
def __init__(self, a, b):
super(S2Child, self).__init__(a)
self.local = b
def __str__(self):
return ("S2Child{S2: %s, local: %d}"
% (super(S2Child, self).__str__(), self.local))
try:
s2child = S2Child(42, 123)
print("s2child = %s" % (s2child,))
print("s2child.Public = %s" % (s2child.Public,))
print("s2child.local = %s" % (s2child.local,))
print("s2child.private = %s" % (s2child.private,))
except Exception as err:
print("caught error: %s" % (err,))
pass
try:
val = structs.S3()
val.X = 3
val.Y = 4
print("s3.X,Y = %d,%d" % (val.X, val.Y))
except Exception as err:
print("caught error: %s" % (err,))
pass
print("OK")