[Python-Dev] PEP for adding an sq_index slot so that any object, a or b, can be used in X[a:b] notation (original) (raw)
Adam Olsen rhamph at gmail.com
Thu Feb 9 22:14:43 CET 2006
- Previous message: [Python-Dev] PEP for adding an sq_index slot so that any object, a or b, can be used in X[a:b] notation
- Next message: [Python-Dev] PEP for adding an sq_index slot so that any object, a or b, can be used in X[a:b] notation
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 2/9/06, Travis E. Oliphant <oliphant.travis at ieee.org> 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 applyslice 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 applyslice and assignslice.
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
- Previous message: [Python-Dev] PEP for adding an sq_index slot so that any object, a or b, can be used in X[a:b] notation
- Next message: [Python-Dev] PEP for adding an sq_index slot so that any object, a or b, can be used in X[a:b] notation
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]