[Python-Dev] NoneType(None) raises exception (original) (raw)
Benjamin Peterson benjamin at python.org
Fri Apr 26 01:35:10 CEST 2013
- Previous message: [Python-Dev] NoneType(None) raises exception
- Next message: [Python-Dev] NoneType(None) raises exception
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
2013/4/25 Ethan Furman <ethan at stoneleaf.us>:
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 = gettype(field) # returns int, bool, str, NoneType, ... result.append(type(field))
if field is None, the resulting call is NoneType(None), and since NoneType doesn't take any parameters we get an exception. Is it worth filing a bug to have NoneType accept one optional argument, which defaults to None, and must be None, else raise an exception?
IMO, that has no interesting semantic meaning and defining your own none function is a perfectly acceptable way of dealing with your problem.
-- Regards, Benjamin
- Previous message: [Python-Dev] NoneType(None) raises exception
- Next message: [Python-Dev] NoneType(None) raises exception
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]