Guido van Rossum wrote: >>>- bool() called without arguments now returns False rather than >>> raising an exception. This is consistent with calling the >>> constructors for the other builtin types -- called without argument >>> they all return the false value of that type. (SF patch #724135) >> >>I seriously question the usefulness of such an approach. It >>doesn't seem to buy us anything and is likely to hide typos >>or progamming errors. > > Types with constructors that insist on an argument are problematic to > generic code that tries to instantiate a type by simply calling it. The types we are talking about all define values -- why would you want to create an object without even knowing the value they represent ? Can you give an example ? BTW, your "simply calling the constructor" is a rather dangerous way of doing inspection: how can you be sure that the constructor has no side-effects ? > I don't think that there's much chance that e.g. str() or int() will > be used by accident and not discovered right away. How's that ? Since it is perfectly valid to write str() and int() without arguments, not even the editor can help notice these cases, so discovery is left to run-time tests and even there an empty string or a zero value may not always trigger the programmer's attention. -- Marc-Andre Lemburg eGenix.com Professional Python Software directly from the Source (#1, Jun 11 2003) >>> Python/Zope Products & Consulting ... http://www.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ EuroPython 2003, Charleroi, Belgium: 13 days left
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