A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2013-April/125599.html below:

[Python-Dev] NoneType(None) raises exception

[Python-Dev] NoneType(None) raises exceptionLennart Regebro 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, ...
>      result.append(type(field))

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. :-)

//Lennart
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4