On 30 Αύγ, 19:41, MRAB <pyt...@mrabarnett.plus.com> wrote: > On 30/08/2010 04:33, Nik the Greek wrote: > > > > > > > > > On 30 Αύγ, 06:12, MRAB<pyt...@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: > ...
# initialize cookie cookie = SimpleCookie() cookie.load( os.environ.get('HTTP_COOKIE', '') ) visitor = cookie.get('visitor') This statement if (visitor.value != 'nikos') and re.search( r'(msn|yandex|13448| spider|crawl)', host ) is None: produces the following error: /home/webville/public_html/cgi-bin/counter.py 93 # do not increment the counter if a Cookie is set to the visitors browser already 94 # ================================================================================================================= 95 if (visitor.value != 'nikos') and re.search( r'(msn|yandex|13448| spider|crawl)', host ) is None: 96 97 print visitor visitor = None, visitor.value undefined, re = <module 're' from '/usr/ lib64/python2.4/re.pyc'>, re.search = <function search>, host = '178-128-217.dynamic.cyta.gr', builtin None = None Why visitor.value is undefined? -- http://mail.python.org/mailman/listinfo/python-list