[issue32112] Should uuid.UUID() accept another UUID() instance?

Irit Katriel report at bugs.python.org
Sun Oct 4 11:42:55 EDT 2020


Irit Katriel <iritkatriel at yahoo.com> added the comment:

I agree with Serhiy that there needs to be a reason for adding this to a class constructor.

In the case of int, this is to implement conversion - it's not accepting int, it's accepting any number (it would be weird of int(3.4) worked and int(3) didn't).  Similarly, complex constructor accepts numbers.

In the case of tuple, bytes, bytearray - the constructor accepts any iterable, again in order to implement type conversion.


So it's not random - these constructors accept objects of the same type because they accept params of a more generic type, in order to provide type conversion functionality.

What functionality would we gain from increasing the API surface of the UUID constructor as you suggest?

----------
nosy: +iritkatriel

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32112>
_______________________________________


More information about the Python-bugs-list mailing list