A certainl part of an if() structure never gets executed.

Chris Angelico rosuav at gmail.com
Wed Jun 12 16:16:44 EDT 2013


On Thu, Jun 13, 2013 at 6:00 AM, Νικόλαος Κούρας <support at superhost.gr> wrote:
> On 12/6/2013 10:48 μμ, Sibylle Koczian wrote:
>>>
>>> if '=' not in ( name and month and year ):
>>> i understand: if '=' not in name AND '=' not in month AND '=' not in year
>>>
>> Wrong. The "'=' not in (...)" first evaluates the expression in
>> parentheses, that's what parentheses are for. And then it looks for '='
>> in the result. And that result is just one of the three values, MRAB
>> told you which one.
>
>
> okey first the expression eval:
>
> ( name and month and year ) = ( name=True and month=True and year=True )
>
> then if '=' not in (name = True and month = True and year = True)
>
> I still do not follow how this works. it just doesn't make any sense to me
> at all.
>
>
>
> if '=' not in ( name and month and year ):
> if '=' not in ( name or month or year ):
>
> I try to read both of them them as an English sentence but i cannot.
> how can you be able to understand this?

Go read the docs. In Python, 'in' is an operator. It behaves like an
operator. It does not behave like magic. Stop expecting magic of
Python.

ChrisA



More information about the Python-list mailing list