isinstance类型记录在哪里? [英] where are isinstance types documented?
问题描述
我正在使用isinstance内置函数。我找到了它的文档,
但是支持的类型上没有文档。
例如isinstance(a,int)工作正常但isinstance(s,string)
不 - 因为''字符串未知''。
我知道如何导入类型模块,然后使用定义的类型
,例如''types.StringType'' - 但文档说从2.2
这不是首选的方式。
那么,'我可以使用isinstance的类型的文档,例如'/ b $ b'为''int''?
非常感谢,
Tony
Hi,
I''m using the isinstance built-in function. I''ve found the docs for it,
but there are no docs on the supported types.
For example isinstance(a, int) works fine but isinstance(s, string)
doesn''t - because ''string is not known''.
I do know how to import the types module and then use defined types
such as ''types.StringType'' - but the documentation says that from 2.2
this is not the preferred way.
So, where''s the documentation for types I can use with isinstance, such
as ''int''?
Many thanks,
Tony
推荐答案
codefire启发我们:
codefire enlightened us with:
我正在使用isinstance内置函数。我找到了
的文档,但是支持的类型没有文档。
I''m using the isinstance built-in function. I''ve found the docs for
it, but there are no docs on the supported types.
支持所有类型/类。
All types/classes are supported.
例如isinstance(a,int)工作正常但是isinstance(s,string)
不 - 因为''字符串未知''。
For example isinstance(a, int) works fine but isinstance(s, string)
doesn''t - because ''string is not known''.
这是因为''string''不是一个类:
print" abc" .__ class __.__ name__
这个名字是''str'',而不是''string''。
Sybren
- -
Sybren St ?? vel
St ?? vel IT - http://www.stuvel.eu/
2006年9月26日02:59:07 -0700,codefire< to **********@gmail.com写道:
On 26 Sep 2006 02:59:07 -0700, codefire <to**********@gmail.comwrote:
我正在使用isinstance内置函数。我找到了它的文档,
但是支持的类型上没有文档。
例如isinstance(a,int)工作正常但isinstance(s,string)
不 - 因为''字符串未知''。
I''m using the isinstance built-in function. I''ve found the docs for it,
but there are no docs on the supported types.
For example isinstance(a, int) works fine but isinstance(s, string)
doesn''t - because ''string is not known''.
在这种情况下,你想要str而不是字符串。
我找不到一个带有内置类型列表的页面(
不会意味着一个人不存在)但我认为你可以找到它们所有
挂在这个页面上:< http://docs.python.org/lib/types.html>。
-
干杯,
Simon B,
si *** @ brunningonline.net ,
http://www.brunningonline.net/simon/blog/
好的Simon,谢谢你链接,我想我可以从那里找出常见的
类型。
Tony
OK Simon, thanks for that link, I think I can ferret out the common
types from there.
Tony
>
这篇关于isinstance类型记录在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!