En Fri, 13 Nov 2009 11:32:37 -0300, Matt Mitchell
<mmitch...@transparent.com> escribió:
answer = tkFileDialog.askdirectory()
if answer is not '':
#do stuff
Although it "reads well", this is *wrong*. You want != here, not the `is
not` operator.
if answer != '': ...
If you want to compare the *values* of two objects, to see if they are
equal or not, use == or !=.
If you want to compare *identity*, to see if two results refer to the very
same object or not, use `is` or `is not`
(In your example, it *may* appear to work, because CPython optimizes very
short strings like 'a' or '', but you should not rely on this optimization)
--
Gabriel Genellina
--
http://mail.python.org/mailman/listinfo/python-list