dict to boolean expression, how to?

Chris Angelico rosuav at gmail.com
Fri Aug 1 09:04:03 EDT 2014


On Fri, Aug 1, 2014 at 10:45 PM, Alex van der Spek <zdoor at xs4all.nl> wrote:
> how would you make a boolean expression like this:
>
> bool = (('a' == 1) & ('A' == 0) |
>         ('b' == 1) & ('B' == 0) |
>         ('c' == 1) & ('C' == 0))

Not sure what the use of this is, because 'a' will never be equal to
1. Are you trying to magically fetch names from your environment?
Because that's usually a bad idea.

ChrisA



More information about the Python-list mailing list