Python checking for None/Null values

2006-08-11 Thread Fuzzydave
Okay, I have been handed a python project and working through it I have had to add a report. I am returning 10 variables the results of an SQL Query and as usual the number of results vary from 1 result to 10 results so I implemented a check to see if the array item was empty or not. The code is

Re: Python checking for None/Null values

2006-08-11 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Fuzzydave wrote: > but regardless i am getting the error below and i can't seen to resolve > this, what am i > doing wrong? > > Traceback (most recent call last): File > "/home/phillipsd/work/medusa-new/htdocs/pricingrep.cgi", line 326, in ? > if historyRep[8]==None: Index

Re: Python checking for None/Null values

2006-08-11 Thread Fuzzydave
> `historyRep` seems to be shorter than you think it is. Try printing it > too see what it actually contains. > > Ciao, > Marc 'BlackJack' Rintsch HistoryRep is an array value so historyRep[0] to [7] all have values in them but historyRep[8] and [9] do not as the query does not always retur

Re: Python checking for None/Null values

2006-08-11 Thread Fuzzydave
> Check with "if history8 is not None". Won't help your problem, but it > is a bit more pythonic code ;-) > > Sybren Actually i tried that as well when i was fooling around, atm i am less concenred with pythonic code and making it work in the first place. The entire program to be fair is a bit mes

Re: Python checking for None/Null values

2006-08-11 Thread bearophileHUGS
Fuzzydave: > I am trying to check all of the historyRep items > to check if they are empty/null/None (whatever the term is in python) An item can't be empty in Python,and null doesn't exist, it can be the object None. But probly that's not your case. > I did print > historyRep[8] out and it fal

Re: Python checking for None/Null values

2006-08-11 Thread Fuzzydave
> Note: sometimes having a clean and readable program is better than > having a running program that you can't read, because you can fix the > the first one, and it can teach you something. > > Bye, > bearophile Thanks for your help and suggestions i'll give them a shot. Unfortunatly when working

Re: Python checking for None/Null values

2006-08-11 Thread John Machin
Fuzzydave wrote: > > HistoryRep is an array value so historyRep[0] to [7] all have values > in them but historyRep[8] and [9] do not as the query does not always > return a full 10 values. I am trying to check all of the historyRep > items > to check if they are empty/null/None (whatever the term i

Re: Python checking for None/Null values

2006-08-11 Thread Peter Otten
Fuzzydave wrote: > Okay, I have been handed a python project and working through it I have > had to add a report. I am returning 10 variables the results of an SQL > Query and as usual the number of results vary from 1 result to 10 results > so I implemented a check to see if the array item was em

Re: Python checking for None/Null values

2006-08-11 Thread Fuzzydave
> [EMAIL PROTECTED] wrote: > A way to solve your problem is to see how many elements the list > contains with > len(sequence) cheers after your post went of to try it and it worked first time thanks for being helpful and plesant :) Fuzzy -- http://mail.python.org/mailman/listinfo/python-list