Hướng dẫn python check if none
Out of these not None tests.
Which one is preferable, and why?
lospejos 1,9683 gold badges19 silver badges33 bronze badges asked Oct 19, 2010 at 3:20
prosseekprosseek 174k200 gold badges549 silver badges848 bronze badges 2
is the Pythonic idiom for testing that a variable is not set to As for why this is preferred to
this is simply part of the Zen of Python: "Readability counts." Good Python is often close to good pseudocode.
answered Oct 19, 2010 at 3:24
9 From, Programming Recommendations, PEP 8:
PEP 8 is essential reading for any Python programmer.
answered Oct 19, 2010 at 3:35
johnsywebjohnsyweb 132k23 gold badges178 silver badges239 bronze badges 0 The best bet with these types of questions is to see exactly what python does. The
Notice that the last two cases reduce to the same sequence of operations, Python reads As pointed out by other answers, using
answered Oct 20, 2013 at 19:44
SheetJSSheetJS 21.7k12 gold badges63 silver badges75 bronze badges 2 Either of the latter two, since answered Oct 19, 2010 at 3:23
1 |