Problem checking an existing browser cookie

MRAB python at mrabarnett.plus.com
Mon Aug 30 19:50:21 CEST 2010


On 30/08/2010 18:16, Nik the Greek wrote:
> On 30 Αύγ, 19:41, MRAB<pyt... at mrabarnett.plus.com>  wrote:
>> On 30/08/2010 04:33, Nik the Greek wrote:
>>
>>
>>
>>
>>
>>
>>
>>> On 30 Αύγ, 06:12, MRAB<pyt... at mrabarnett.plus.com>    wrote:
>>
>>>> This part:
>>
>>>>        ( not mycookie or mycookie.value != 'nikos' )
>>
>>>> is false but this part:
>>
>>>>        re.search( r'(msn|yandex|13448|spider|crawl)', host ) is None
>>
>>>> is true because host doesn't contain any of those substrings.
>>
>>> So, the if code does executed because one of the condition is true?
>>
>>> How should i write it?
>>
>>> I cannot think clearly on this at all.
>>
>>> I just wan to tell it to get executed  ONLY IF
>>
>>> the cookie values is not 'nikos'
>>
>>> or ( don't knwo if i have to use and or 'or' here)
>>
>>> host does not contain any of the substrings.
>>
>>> What am i doign wrong?!
>>
>> It might be clearer if you reverse the condition and say:
>>
>>       me_visiting = ...
>>       if not me_visiting:
>>           ...
>
> I don't understand what are you trying to say
>
> Please provide a full example.
>
> You mean i should try it like this?
>
> unless ( visitor and visitor.value == 'nikos' ) or re.search( r'(msn|
> yandex|13448|spider|crawl)', host ) not None:
>
> But isnt it the same thing like the if?

My point is that the logic might be clearer to you if you think first
about how you know when you _are_ the visitor.



More information about the Python-list mailing list