【发布时间】:2016-08-04 03:49:14
【问题描述】:
'=' not in access and name + '.' not in access
我希望避免在一行 Python 代码中出现 not in accesss 的多重性。为方便起见,我在重复次数较多的情况下使用了表达式求值循环,但在重复次数较多的情况下似乎很奇怪。
【问题讨论】:
-
我认为您以某种方式回答了自己的问题:这真的值得吗?
-
这似乎太不合Python了。
-
re.search('=|' + name + '[.]', access) is None避免了重复,但我不认为我的比你的更好。 -
我不认为为了不重复 3 个单词而使用一个可以说是晦涩难懂的表达方式更符合 Pythonic...
-
我猜我有点期待像
'=', name + '.' not in access这样美观的东西。
标签: python repeat non-repetitive