Showing content from http://mail.python.org/pipermail/python-dev/attachments/20070222/025eff8f/attachment.htm below:
<br><br><div><span class="gmail_quote">On 2/22/07, <b class="gmail_sendername">Neal Becker</b> <<a href="mailto:ndbecker2@gmail.com">ndbecker2@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Mike Klaas wrote:<br><br>> On 2/22/07, Neal Becker <<a href="mailto:ndbecker2@gmail.com">ndbecker2@gmail.com</a>> wrote:<br>><br>>> Well consider this:<br>>> >>>str (4)<br>>> '4'
<br>>> >>>int(str (4))<br>>> 4<br>>> >>>str (False)<br>>> 'False'<br>>><br>>> >>>bool(str(False))<br>>> True<br>>><br>>> Doesn't this seem a bit inconsisent?
<br>><br>> Virtually no python objects accept a stringified version of themselves<br>> in their constructor:<br>><br>>>>> str({})<br>> '{}'<br>>>>> dict('{}')<br>> Traceback (most recent call last):
<br>> File "<stdin>", line 1, in <module><br>> ValueError: dictionary update sequence element #0 has length 1; 2 is<br>> required<br>>>>> str([])<br>> '[]'<br>>>>> list('[]')
<br>> ['[', ']']<br>><br>> Python is not Perl.<br>><br>Except, all the numeric types do, including int, float, and complex. But<br>not bool. In fact, this is not just academic. The fact that other numeric
<br>types act this way leaves a reasonable expectation that bool will.<br>Instead, bool fails in _the worst possible way_: it silently gives a _wrong<br>result_.</blockquote><div><br>i agree with mike; it would just be asking for trouble. (have you ever been bitten by the Perl behavior where the string '0' is considered false? it's a nasty, nasty problem to debug.)
<br><br>neal, you may be confusing the concepts of "convert data from one type to another" and "read the printed representation of data". <br></div><br><br>ben</div>
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