On 2/9/06, Travis E. Oliphant <[EMAIL PROTECTED]> wrote: > I'm a little confused. Is your opposition solely due to the fact that > you think float's __int__ method ought to raise exceptions and the > apply_slice code should therefore use the __int__ slot? > > In theory I can understand this reasoning. In practice, however, the > __int__ slot has been used for "coercion" and changing the semantics of > int(3.2) at this stage seems like a recipe for lots of code breakage. I > don't think something like that is possible until Python 3k. > > If that is not your opposition, please be more clear. Regardless of how > it is done, it seems rather unPythonic to only allow 2 special types to > be used in apply_slice and assign_slice.
Yes, that is the basis of my opposition, and I do understand it would take a long time to change __int__. What is the recommended practice for python? I can think of three distinct categories of behavior: - float to str. Some types converted to str might by lossy, but in general it's a very drastic conversion and unrelated to the others - float to Decimal. Raises an exception because it's usually lossy. - Decimal to int. Truncates, quite happily losing precision.. I guess my confusion revolves around float to Decimal. Is lossless conversion a good thing in python, or is prohibiting float to Decimal conversion just a fudge to prevent people from initializing a Decimal from a float when they really want a str? -- Adam Olsen, aka Rhamphoryncus _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com