[issue35115] UUID objects can't be casted by `hex()`

2018-10-31 Thread fcurella
fcurella added the comment: I'm not sure what can be done to make UUIDs work with `hex()`. The only way I see is to add back something _like_ `__hex__`, but with a different name. But in that case, I can see how the same arguments that were originally brought up against `__hex__` could

[issue35115] UUID objects can't be casted by `hex()`

2018-10-31 Thread Mark Dickinson
Mark Dickinson added the comment: > I don't see large usability difference between 'uuid={:x}'.format(u) and > 'uuid={.hex}'.format(u). Agreed. @fcurella: marking as enhancement is fine, but you need to be specific about what exact enhancement you're proposing. Adding __hex__ back isn't a

[issue35115] UUID objects can't be casted by `hex()`

2018-10-30 Thread fcurella
Change by fcurella : -- status: -> open ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue35115] UUID objects can't be casted by `hex()`

2018-10-30 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Note that str() for UUIDs already returns the hexadecimal representation, just with minuses. I don't see large usability difference between 'uuid={:x}'.format(u) and 'uuid={.hex}'.format(u). And in many case 'uuid={}'.format(u) is appropriate as well.

[issue35115] UUID objects can't be casted by `hex()`

2018-10-30 Thread Mark Dickinson
Mark Dickinson added the comment: Agreed that UUID should not implement `__index__`. I wouldn't expect to be able to use a UUID as a list index, for example. This is marked as "behavior", but I have a hard time seeing this as a bug. It's not even a usability bug, given how easy it is to get

[issue35115] UUID objects can't be casted by `hex()`

2018-10-30 Thread శ్రీనివాస్ రెడ్డి తాటిపర్తి
Change by Srinivas Reddy Thatiparthy(శ్రీనివాస్ రెడ్డి తాటిపర్తి) : -- nosy: +thatiparthy ___ Python tracker ___ ___

[issue35115] UUID objects can't be casted by `hex()`

2018-10-30 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: hex() used the __hex__() special method in Python 2. This was changed in Python 3 for purpose. https://docs.python.org/3/whatsnew/3.0.html#operators-and-special-methods -- nosy: +serhiy.storchaka ___ Python

[issue35115] UUID objects can't be casted by `hex()`

2018-10-30 Thread fcurella
fcurella added the comment: I must admit I was surprised to find out that `hex()` uses `__index__` (which is supposed to return an integer) and not something like a `__hex__` method returning the hex. Maybe we should change the behaviour of `hex()` instead? (in a backward-compatible way,

[issue35115] UUID objects can't be casted by `hex()`

2018-10-30 Thread Ronald Oussoren
Ronald Oussoren added the comment: IMHO implementing "__index__" for UUID would not the correct solution. That method is meant be used by integer-like objects. One of the side effects of implementing "__index__" is that indexing lists with UUID instances would start to work, which is IMHO

[issue35115] UUID objects can't be casted by `hex()`

2018-10-30 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- nosy: +mark.dickinson ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue35115] UUID objects can't be casted by `hex()`

2018-10-30 Thread fcurella
Change by fcurella : -- keywords: +patch pull_requests: +9557 stage: -> patch review ___ Python tracker ___ ___ Python-bugs-list

[issue35115] UUID objects can't be casted by `hex()`

2018-10-30 Thread fcurella
New submission from fcurella : Casting a UUID to an `int` or to a string works as expected: ``` import uuid value = uuid.UUID() str(value) int(value) ``` but casting to an `hex()` raises an exception: ``` import uuid value = uuid.UUID() # uuid instances already have the correct value