documentation on the uuid
module说:
UUID.
variant
07001The UUID variant, which determines the internal
layout of the UUID. This will be one of the integer constants
07002,
07003,
07004,
or
07005.
然后:
uuid.
RESERVED_NCS
07006Reserved for NCS compatibility.
uuid.
RFC_4122
07007Specifies the UUID layout given in 07008.
uuid.
RESERVED_MICROSOFT
07009Reserved for Microsoft compatibility.
uuid.
RESERVED_FUTURE
070010Reserved 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或GitHub),其中包含以下声明:
06001
鉴于我在翻译中看到的结果,这很有道理,但我不能对文档说同样的话.
这是一个简单的文档错误,还是存在这些属性确实是整数的地方,正如文档所承诺的那样?这里发生了什么?
最佳答案 这是文档中的错误.我在
official bug tracker中提交了它,并通过删除“整数”一词修复了它:
I simply remove the type description since I think the type of the constants doesn’t matter here.