コード例 #1
0
ファイル: test.py プロジェクト: zhangdong046/gopy
    print "caught:", err, "| err-type:", type(err)
    pass

p = hi.Person("name")
print p
p = hi.Person("name", 42)
print p
p = hi.Person(Name="name", Age=42)
print p
p = hi.Person(Age=42, Name="name")
print p

## test ctors
print "--- hi.NewPerson('me', 666):", hi.NewPerson("me", 666)
print "--- hi.NewPersonWithAge(666):", hi.NewPersonWithAge(666)
print "--- hi.NewActivePerson(4):", hi.NewActivePerson(4)

## test Couple
print "--- c = hi.Couple()..."
c = hi.Couple()
print c
print "--- c.P1:", c.P1
c.P1 = hi.NewPerson("tom", 5)
c.P2 = hi.NewPerson("bob", 2)
print "--- c:", c

print "--- c = hi.NewCouple(tom, bob)..."
c = hi.NewCouple(hi.NewPerson("tom", 50), hi.NewPerson("bob", 41))
print c
c.P1.Name = "mom"
c.P2.Age = 51
コード例 #2
0
ファイル: test.py プロジェクト: ziux/gopy
    pass

p = hi.Person("name")
print(p)
p = hi.Person("name", 42)
print(p)
p = hi.Person(Name="name", Age=42)
print(p)
p = hi.Person(Age=42, Name="name")
print(p)

## test ctors
print("--- hi.NewPerson('me', 666):", hi.NewPerson("me", 666))
print("--- hi.NewPersonWithAge(666):", hi.NewPersonWithAge(666))
print("--- hi.NewActivePerson(4):")
p = hi.NewActivePerson(4)
print(p)

## test Couple
print("--- c = hi.Couple()...")
c = hi.Couple()
print(c)
print("--- c.P1:", c.P1)
c.P1 = hi.NewPerson("tom", 5)
c.P2 = hi.NewPerson("bob", 2)
print("--- c:", c)

print("--- c = hi.NewCouple(tom, bob)...")
c = hi.NewCouple(hi.NewPerson("tom", 50), hi.NewPerson("bob", 41))
print(c)
c.P1.Name = "mom"