我有一个列表L,x in L如果x是L的成员,则计算结果为True.我可以使用什么代替L来依次x in smth对x的值求值为True?
所以,我需要一些东西,包含所有对象,包括它自己,因为x也可以是这个"smth".
class Universe:
def __contains__(_,x): return True
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
706 次 |
| 最近记录: |