Logical AND question

3c273 nospam at nospam.com
Fri May 14 11:04:21 EDT 2004


Thank you both :-)

"Peter Otten" <__peter__ at web.de> wrote in message
news:c808i3$aen$06$1 at news.t-online.com...
> Tor Iver Wilhelmsen wrote:
>
> > "3c273" <nospam at nospam.com> writes:
> >
> >> >>> if s and t == '':
> >>  print "This doesn't work!"
> >
> > This is really
> >
> > if (s) and (t == '')
> >
> > which evaluates to false since "if (s)" returns false for the empty
> > string.
>
> The original poster probably wants
>
> >>> if s == t == "":
> ...     print "this works"
> ...
> this works
> >>>
>
> or the conventional
>
> >>> if s == "" and t == "":
> ...     print "but this is more common"
> ...
> but this is more common
> >>>
>
> Peter
>





More information about the Python-list mailing list