When will the UUID option be integer?

The documentation in the module uuidsays:

UUID. variant

A UUID variant that defines the internal UUID layout. This will be one of the integer constants RESERVED_NCS , RFC_4122 , RESERVED_MICROSOFT , or RESERVED_FUTURE .

And later:

UUID. RESERVED_NCS

Reserved for compatibility with NCS.

UUID. RFC_4122

Defines the UUID layout given in RFC 4122 .

UUID. RESERVED_MICROSOFT

Reserved for compatibility with Microsoft.

UUID. RESERVED_FUTURE

Reserved for future determination.

Given this, I expected to see integers when accessing these attributes. However:

>>> import uuid
>>> u = uuid.uuid4()
>>> u.variant
'specified in RFC 4122'
>>> uuid.RESERVED_NCS
'reserved for NCS compatibility'
>>> uuid.RFC_4122
'specified in RFC 4122'
>>> uuid.RESERVED_MICROSOFT
'reserved for Microsoft compatibility'
>>> uuid.RESERVED_FUTURE
'reserved for future definition'

This gives the same result in 2.7.9 and 3.4.2, and I did not find any documentation for any version that suggests that these constants can be strings.

, , ( SVN GitHub), :

RESERVED_NCS, RFC_4122, RESERVED_MICROSOFT, RESERVED_FUTURE = [
    'reserved for NCS compatibility', 'specified in RFC 4122',
    'reserved for Microsoft compatibility', 'reserved for future definition']

, , , .

​​ -, , promises? ?

+4
1

. , , "":

I will simply delete the type description, since I think the type of constants does not matter here.

+2
source

Source: https://habr.com/ru/post/1657009/


All Articles