UUID变体什么时候是整数?
When would a UUID variant be an integer?
documentation on the uuid
module 说:
UUID.
variant
¶
The UUID variant, which determines the internal
layout of the UUID. This will be one of the integer constants
RESERVED_NCS,
RFC_4122,
RESERVED_MICROSOFT,
or
RESERVED_FUTURE.
以后:
uuid.
RESERVED_NCS
¶
Reserved for NCS compatibility.
uuid.
RFC_4122
¶
Specifies the UUID layout given in RFC 4122.
uuid.
RESERVED_MICROSOFT
¶
Reserved for Microsoft compatibility.
uuid.
RESERVED_FUTURE
¶
Reserved for future definition.
鉴于此,我希望在访问这些属性时看到整数。然而:
>>> 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'
这在 2.7.9 和 3.4.2 中产生了相同的结果,我还没有找到任何版本的文档表明这些常量可能是字符串。
我能在这个问题上产生的最相关的搜索结果恰好是该模块的源代码(在 SVN or 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']
考虑到我在解释器中看到的结果,这是完全有道理的,但我不能对文档说同样的话。
这是一个简单的文档错误,还是在某些地方这些属性确实是整数,正如文档所承诺的那样?这是怎么回事?
这是文档中的错误。我在 official bug tracker 中提交了它,并且已通过删除单词 "integer":
来修复它
I simply remove the type description since I think the type of the constants doesn't matter here.
documentation on the uuid
module 说:
UUID.
variant
¶The UUID variant, which determines the internal layout of the UUID. This will be one of the integer constants RESERVED_NCS, RFC_4122, RESERVED_MICROSOFT, or RESERVED_FUTURE.
以后:
uuid.
RESERVED_NCS
¶Reserved for NCS compatibility.
uuid.
RFC_4122
¶Specifies the UUID layout given in RFC 4122.
uuid.
RESERVED_MICROSOFT
¶Reserved for Microsoft compatibility.
uuid.
RESERVED_FUTURE
¶Reserved for future definition.
鉴于此,我希望在访问这些属性时看到整数。然而:
>>> 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'
这在 2.7.9 和 3.4.2 中产生了相同的结果,我还没有找到任何版本的文档表明这些常量可能是字符串。
我能在这个问题上产生的最相关的搜索结果恰好是该模块的源代码(在 SVN or 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']
考虑到我在解释器中看到的结果,这是完全有道理的,但我不能对文档说同样的话。
这是一个简单的文档错误,还是在某些地方这些属性确实是整数,正如文档所承诺的那样?这是怎么回事?
这是文档中的错误。我在 official bug tracker 中提交了它,并且已通过删除单词 "integer":
来修复它I simply remove the type description since I think the type of the constants doesn't matter here.