Path: csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.016 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'else:': 0.03; 'elif': 0.05; '"0"': 0.16; '12:17,': 0.16; 'andreas': 0.16; 'bye,': 0.16; 'does,': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; 'sys.exit(0)': 0.16; 'then?': 0.16; 'year)': 0.16; '\xce\xb3\xce\xaf\xce\xbd\xce\xb5\xce\xb9': 0.16; 'wrote:': 0.18; 'seems': 0.21; 'header:User-Agent:1': 0.23; 'char': 0.24; 'exists': 0.24; 'month,': 0.24; '\xce\xb4\xce\xb5\xce\xbd': 0.24; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; "doesn't": 0.30; '\xcf\x84\xce\xbf': 0.30; 'skip:c 30': 0.32; 'actual': 0.34; 'but': 0.35; 'possible': 0.36; 'wrong': 0.37; 'problems': 0.38; 'skip:\xcf 20': 0.38; 'to:addr:python- list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'most': 0.60; "you're": 0.61; 'name': 0.63; 'header:Reply-To:1': 0.67; 'reply-to:no real name:2**0': 0.71; '8bit%:100': 0.72; 'reply- to:addr:python.org': 0.84; 'subject:gets': 0.84; '\xce\xb1\xcf\x86\xce\xbf\xcf\x8d': 0.84; '\xce\xbf\xcf\x8d\xcf\x84\xce\xb5': 0.84 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=KrN0hwmN c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=oyR3mlnJdzkA:10 a=ZBT6mux8yFEA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=IkcTkHD0fZMA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=tXfRgeB1Xo0A:10 a=_xWkMZaRGQ2j2u2EAd0A:9 a=QEXdDO2ut3YA:10 X-AUTH: mrabarnett:2500 Date: Wed, 12 Jun 2013 17:40:29 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 MIME-Version: 1.0 To: python-list@python.org Subject: Re: A certainl part of an if() structure never gets executed. References: <2bc90d3b-09c2-4315-9357-ff7f039465e0@googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: python-list@python.org List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 43 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1371055227 news.xs4all.nl 15949 [2001:888:2000:d::a6]:44698 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:47817 On 12/06/2013 12:17, Νικόλαος Κούρας wrote: > >> As with most of your problems you are barking up the wrong tree. >> Why not use the actual value you get from the form to check whether you >> have a valid month? >> Do you understand why "0" is submitted instead of "=========="? >> >> Bye, Andreas > > I have corrected the enumerate loop but it seems thet now the year works > and the selected name nad month fail: > > if '=' not in ( name and month and year ): > cur.execute( '''SELECT * FROM works WHERE clientsID = (SELECT id FROM > clients WHERE name = %s) and MONTH(lastvisit) = %s and YEAR(lastvisit) = > %s ORDER BY lastvisit ASC''', (name, month, year) ) > elif '=' not in ( month and year ): > cur.execute( '''SELECT * FROM works WHERE MONTH(lastvisit) = %s and > YEAR(lastvisit) = %s ORDER BY lastvisit ASC''', (month, year) ) > elif '=' not in year: > cur.execute( '''SELECT * FROM works WHERE YEAR(lastvisit) = %s ORDER > BY lastvisit ASC''', year ) > else: > print( '

Πώς να γίνει αναζήτηση αφού δεν επέλεξες > ούτε πελάτη ούτε μήνα ή τουλάχιστον το έτος?' ) > print( ' content="5;/cgi-bin/pelatologio.py">' ) > sys.exit(0) > > > i tried in , not in and all possible combinations. but somehow it > confuses me. > > doesn't that mean? > > if '=' not in ( name and month and year ): > > if '=' does not exists as a char inside the name and month and year > variables? > > i think it does, but why it fails then? > You think it does, but you're wrong.