[Python-Dev] NoneType(None) raises exception
Antoine Pitrou
solipsis at pitrou.net
Fri Apr 26 09:01:07 CEST 2013
On Thu, 25 Apr 2013 16:09:41 -0700
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))
I don't understand what the use case is. If you already have a value of
None, why do you call NoneType on it again?
Perhaps you should write:
if not isinstance(type, field):
field = type(field)
Rehatds
Antoine.
More information about the Python-Dev
mailing list