Path: csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'charset:iso-8859-7': 0.04; 'from:addr:yahoo.co.uk': 0.04; 'elif': 0.05; 'back.': 0.09; 'data:': 0.09; 'happen?': 0.09; 'if,': 0.09; 'lawrence': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; 'bug': 0.12; '*only*': 0.16; '......': 0.16; 'grounds': 0.16; 'hits': 0.16; 're.search(': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'selects': 0.16; 'sys.exit(0)': 0.16; 'year)': 0.16; 'wrote:': 0.18; 'coding': 0.22; 'header:User-Agent:1': 0.23; 'error': 0.23; 'form:': 0.24; 'month,': 0.24; 'possibly': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'ball': 0.31; "i'd": 0.34; "can't": 0.35; 'but': 0.35; 'next': 0.36; 'should': 0.36; 'to:addr :python-list': 0.38; 'reported': 0.39; 'structure': 0.39; 'to:addr:python.org': 0.39; 'either': 0.39; 'received:org': 0.40; 'then,': 0.60; 'black': 0.61; 'name': 0.63; 'here': 0.66; 'watching': 0.68; 'results': 0.69; 'money': 0.72; 'subject:gets': 0.84; 'white,': 0.84; '\xe3\xdf\xed\xe5\xe9': 0.84; 'received:89': 0.85 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: A certainl part of an if() structure never gets executed. Date: Tue, 11 Jun 2013 23:14:08 +0100 References: <2bc90d3b-09c2-4315-9357-ff7f039465e0@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-7; format=flowed Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: host-89-240-174-199.as13285.net User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 In-Reply-To: <2bc90d3b-09c2-4315-9357-ff7f039465e0@googlegroups.com> X-Antivirus: avast! (VPS 130611-1, 11/06/2013), Outbound message X-Antivirus-Status: Clean X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list 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: 48 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1370988859 news.xs4all.nl 15895 [2001:888:2000:d::a6]:60117 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:47706 On 11/06/2013 21:20, Νικόλαος Κούρας wrote: > [code] > if not re.search( '=', name ) and not re.search( '=', month ) and not re.search( '=', 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 re.search( '=', month ) and not re.search( '=', year ): > cur.execute( '''SELECT * FROM works WHERE MONTH(lastvisit) = %s and YEAR(lastvisit) = %s ORDER BY lastvisit ASC''', (month, year) ) > elif not re.search( '=', year ): > cur.execute( '''SELECT * FROM works WHERE YEAR(lastvisit) = %s ORDER BY lastvisit ASC''', year ) > else: > print('''

Πώς να γίνει αναζήτηση αφού δεν επέλεξες ούτε πελάτη ούτε μήνα ή τουλάχιστον το έτος?''') > print( '''''' ) > sys.exit(0) > > data = cur.fetchall() > > hits = money = 0 > > for row in data: > hits += 1 > money = money + row[2] > > ...... > ...... > selects based on either name, month, year or all of them > [/code] > > > The above if structure works correctly *only* if the user sumbits by form: > > name, month, year > or > month, year > > If, he just enter a year in the form and sumbit then, i get no error, but no results displayed back. > > Any ideas as to why this might happen? > On the grounds that you can't possibly have made a coding error I'd say this is a Python bug which should be reported here bugs.python.org. -- "Steve is going for the pink ball - and for those of you who are watching in black and white, the pink is next to the green." Snooker commentator 'Whispering' Ted Lowe. Mark Lawrence