[Python-Dev] NoneType(None) raises exception
regebro at gmail.com
Fri Apr 26 09:19:12 CEST 2013
On Fri, Apr 26, 2013 at 1:09 AM, Ethan Furman <ethan at stoneleaf.us> wrote:
> We just fixed NoneType() to return None instead of raising an exception.
> Another use-case for calling NoneType is working with ORMs:
> result = 
> for field in row:
> type = get_type(field) # returns int, bool, str, NoneType, ...
Having it return NoneType there seems a strange thing to do, as have a
None field makes no sense. Why would you have a column that can only
contain the value None? What is returning NoneType at that point
supposed to signify?
If it's supposed to signify that the value is NULL, I think the above
code is a very strange way of handling that. get_type(field) should
reasonably return the type of the column, not the type of the value
you got, as that would be just type(field) and doing
type(field)(field) is a bit pointless. :-)
More information about the Python-Dev