def comPack2(seat) -> ChunckedData:
"""
compress the return packet of -1,
whose packetType number is 2
"""
ret = ChunckedData(2, chosenSeat=seat)
return ret
if (type == -1):
"""
-1是服务器发出的建立连接的信息
"""
print("%d seat(s) remained and the seats you can choose are :" %
(ret.content['playerRemaining']))
for x in ret.content['playerSeats']:
print(x, end=' ')
print("Please enter the number of seat you choose: ")
chosenSeat = input()
return comPack2(chosenSeat)
client_subthread.py文件中出现了如下形式的代码:
我看不出来把构造函数再wrap一层的必要性,而且如果真的要写成函数,用lambda表达式似乎更好
这个函数在程序的这个地方调用:
既然只是
return comPack2(chosenSeat)
,代码里又没有对这些东西做额外的操作,为什么不直接return新对象呢?