change a value to NULL?
Bell, Kevin
kevin.bell at slcgov.com
Wed Oct 5 12:49:48 EDT 2005
Just tested it. Access does recognize None as null/blank/etc when None
is passed in from python.
Kevin Bell
-----Original Message-----
From: python-list-bounces+kevin.bell=slcgov.com at python.org
[mailto:python-list-bounces+kevin.bell=slcgov.com at python.org] On Behalf
Of Bell, Kevin
Sent: Wednesday, October 05, 2005 10:33 AM
To: python-list at python.org
Subject: RE: change a value to NULL?
Thanks, being new to this, I wasn't sure if I should use None, Null,
Nope, Nada, or Nil!
I'm going to be loading a list into an MS Access db. Do you know if I
load None into an Access field if Access will recognize that as
blank/null? I suppose I'll just go test it out.
Thanks again...
Kevin Bell
-----Original Message-----
From: Laszlo Zsolt Nagy [mailto:gandalf at designaproduct.biz]
Sent: Wednesday, October 05, 2005 10:18 AM
To: Bell, Kevin; python-list at python.org
Subject: Re: change a value to NULL?
Bell, Kevin wrote:
>I'm pulling a list of numbers from MS Excel, but occasionally if there
>is no data from excel, the value is an asterisk, but I need to make it
>null.
>
>What is the best way to do that? Thus far, I'm using:
>
>
>for value in myRange:
> try:
> intV = int(value)
> print intV
> except:
> print "its an asterisk"
>
>
I'm affraid I did not understand what is your real problem.
Here is an answer, anyway.
When converting a string intoto an int, you should use TypeError to trap
type errors only:
try:
intV = int(value)
except TypeError:
intV = None
print intV # It will be None if 'value' is not an int
Best,
Les
--
http://mail.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list