Mr.SpOOn mr.spoo...@gmail.com wrote in message
news:mailman.492.1258380560.2873.python-l...@python.org...
In [13]: ('b3' and '5') in l or ('3' and 'b3') in l
Out[13]: True
For anything more than the simplest cases, you might want use sets.
That might be the correct data type from the start,
Thanks everybody for all the answers and explanations.
In the end maybe it is simpler if I use sets for these tests.
Thanks again.
--
http://mail.python.org/mailman/listinfo/python-list
Hi,
I'm trying to use logical operators (or, and) with the in statement,
but I'm having some problems to understand their behavior.
In [1]: l = ['3', 'no3', 'b3']
In [2]: '3' in l
Out[2]: True
In [3]: '3' and '4' in l
Out[3]: False
In [4]: '3' and 'no3' in l
Out[4]: True
This seems to work as
Sorry for replying to myself, but I think I understood why I was wrong.
The correct statement should be something like this:
In [13]: ('b3' and '5') in l or ('3' and 'b3') in l
Out[13]: True
--
http://mail.python.org/mailman/listinfo/python-list
On 02:02 pm, mr.spoo...@gmail.com wrote:
Hi,
I'm trying to use logical operators (or, and) with the in statement,
but I'm having some problems to understand their behavior.
and and or have no particular interaction with in.
In [1]: l = ['3', 'no3', 'b3']
In [2]: '3' in l
Out[2]: True
In
On Mon, Nov 16, 2009 at 6:02 AM, Mr.SpOOn mr.spoo...@gmail.com wrote:
Hi,
I'm trying to use logical operators (or, and) with the in statement,
but I'm having some problems to understand their behavior.
In [1]: l = ['3', 'no3', 'b3']
In [2]: '3' in l
Out[2]: True
In [3]: '3' and '4' in l
On Tue, Nov 17, 2009 at 12:02 AM, Mr.SpOOn mr.spoo...@gmail.com wrote:
Hi,
I'm trying to use logical operators (or, and) with the in statement,
but I'm having some problems to understand their behavior.
Hey Carlo, I think your issue here is mistaking 'in' as a statement. It's
just another
On Mon, Nov 16, 2009 at 6:08 AM, Mr.SpOOn mr.spoo...@gmail.com wrote:
Sorry for replying to myself, but I think I understood why I was wrong.
The correct statement should be something like this:
In [13]: ('b3' and '5') in l or ('3' and 'b3') in l
Out[13]: True
No, you've just run into
On Tue, Nov 17, 2009 at 12:08 AM, Mr.SpOOn mr.spoo...@gmail.com wrote:
Sorry for replying to myself, but I think I understood why I was wrong.
The correct statement should be something like this:
In [13]: ('b3' and '5') in l or ('3' and 'b3') in l
Out[13]: True
Carlo, I'm not sure what
Here I expected to get True in the second case too, so clearly I don't
really get how they work.
You're seeing short-circuit evaluation:
3 or 4 # true
'3'
'4' or '3' # true
'4'
'4' in l# false
False
'3' or False # true
'3'
'4' or '42' in l # true: same as '4' or
On Mon, Nov 16, 2009 at 6:23 AM, Xavier Ho cont...@xavierho.com wrote:
snip
'3' in l and 'no3' in l
True
AND operator has a higher precedence, so you don't need any brackets here, I
think. But anyway, you have to use it like that. So that's something you'll
have to fix first.
Er, you mean
On Tue, Nov 17, 2009 at 12:46 AM, Chris Rebert c...@rebertia.com wrote:
On Mon, Nov 16, 2009 at 6:23 AM, Xavier Ho cont...@xavierho.com wrote:
AND operator has a higher precedence, so you don't need any brackets
here, I
think. But anyway, you have to use it like that. So that's something
12 matches
Mail list logo