|
- class test:
- def __init__(self, name, att):
- self.name = name
- self.att = att
- def func(a1: test, a2: test):
- return 0 if a1.att >= a2.att else 1
- a1 = test("a1", 1)
- a2 = test("a2", 2)
- a3, a4 = [a1, a2][func(a1, a2)], [a1, a2][int(not(func(a1, a2)))]
- print(a3.name, a4.name)
复制代码 |
|