[Python-ideas] bool.from_config_str()
Michael Selik
michael.selik at gmail.com
Sun Jun 12 21:00:57 EDT 2016
More information about the Python-ideas mailing list
Sun Jun 12 21:00:57 EDT 2016
- Previous message (by thread): [Python-ideas] bool.from_config_str()
- Next message (by thread): [Python-ideas] bool.from_config_str()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Sun, Jun 12, 2016 at 7:53 PM <jab at math.brown.edu> wrote: > >>> bool.from_config_str('false') > False > Why put the word "config" in the method name rather than just ``bool.from_str``? Why not just check for the truth values? config = 'False' try: value = bool(float(config)) except (TypeError, ValueError): value = config.casefold() == 'true' I agree it's frustrating to have the 4 lines. Perhaps this is yet another case that would be improved by exception-catching expressions (PEP 463)? Unless those 4 lines occur very frequently, this feels like a bit too special-case for a bool method. It feels more like it's part of a library offering environment or config utilities. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160613/ffa6e630/attachment.html>
- Previous message (by thread): [Python-ideas] bool.from_config_str()
- Next message (by thread): [Python-ideas] bool.from_config_str()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-ideas mailing list