This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author larry
Recipients larry, serhiy.storchaka, zach.ware
Date 2015-04-19.05:34:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1429421643.65.0.224102646282.issue23920@psf.upfronthosting.co.za>
In-reply-to
Content
I'm now converging on changing types= to accept a set of real types, see issue #24001.  That change has an impact on this decision.

(By the way, let's assume that if "nullable", I have to rename it to "accepts_none".  I'll use that name below.)

What makes me want to use types={NoneType} is the Zen: "There should be one (and preferably only one) obvious way to do it", and "Special cases aren't special enough to break the rules".  But Argument Clinic's input isn't Python, so maybe the Zen doesn't need to be as strict here.

What makes me not want to use types={NoneType} is that it's generally longer, and it requires you to know the default types accepted by a converter.

Currently (after the rename) to get format unit "z" you write:
   s: str(accepts_none=True)
If I changed this (and #24001 goes in), you'd have to write:
   s: str(types={str, NoneType})

It requires you to know all the default types of the converter in question, just so you can add NoneType to it.  And it's longer.

We could fix it if converter classes generally published their default types.  So you could say
   s: str(types=str_converter.default_types + {NoneType})
And it's even longer.  So we probably shouldn't bother with this.

On the other hand, out of all the converters that exist, only three have a types= argument (int, str, and Py_buffer).  And it's not unreasonable to expect the caller to know the default types= set.  Although, we'd have to add types= to a fourth converter (Py_UNICODE), which currently supports nullable= but doesn't need types=.
History
Date User Action Args
2015-04-19 05:34:03larrysetrecipients: + larry, zach.ware, serhiy.storchaka
2015-04-19 05:34:03larrysetmessageid: <1429421643.65.0.224102646282.issue23920@psf.upfronthosting.co.za>
2015-04-19 05:34:03larrylinkissue23920 messages
2015-04-19 05:34:03larrycreate