[Tutor] question concerning Boolean operators
jim stockford
jim at well.com
Fri Mar 21 00:55:17 CET 2008
i'm guessing assignment, which actually associates
a reference, will skip referencing an identifier to a null
and will make the association (assignment) to the first
non-null value in the expression, which is string2 in
this case. that the identifier is non_null is immaterial;
you could write
>>> string1, string2, string3 = '', 'Trondheim', 'Hammer Dance'
>>> jackson = string1 or string2 or string3
>>> jackson
'Trondheim'
On Mar 20, 2008, at 4:32 PM, Guba wrote:
> Dear list,
>
> from Guido's tutorial:
>
> It is possible to assign the result of a comparison or other Boolean
> expression to a variable. For example,
>
> >>> string1, string2, string3 = '', 'Trondheim', 'Hammer Dance'
> >>> non_null = string1 or string2 or string3
> >>> non_null
> 'Trondheim'
>
> How does this work?? How does Python know that we are looking for
> non_null? After all, we don't provide this information here, right? (I
> take non_null is a variable.)
> I must be missing something... Can anyone help?
>
> Many thanks,
>
> Guba
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
More information about the Tutor
mailing list