R
Russel Walker
The type() builtin according to python docs, returns a "type object".
http://docs.python.org/2/library/types.html
And in this module is bunch of what I assume are "type objects". Is this correct?
http://docs.python.org/2/library/functions.html#type
And type(), aside from being used in as an alternative to a class statement to create a new type, really just returns the object class, doesn't it?
If type() didn't exist would it be much more of a matter than the following?:
def type(x):
return x.__class__
What is the purpose of type()?
What exactly is a "type object"? Is it a "class"?
What is the purpose of the types module?
I understand the purpose of isinstance and why it's recommended over something like (type(1) is int). Because isinstance will also return True if the object is an instance of a subclass.
def __init__(self):
pass
http://docs.python.org/2/library/types.html
And in this module is bunch of what I assume are "type objects". Is this correct?
http://docs.python.org/2/library/functions.html#type
And type(), aside from being used in as an alternative to a class statement to create a new type, really just returns the object class, doesn't it?
If type() didn't exist would it be much more of a matter than the following?:
def type(x):
return x.__class__
What is the purpose of type()?
What exactly is a "type object"? Is it a "class"?
What is the purpose of the types module?
I understand the purpose of isinstance and why it's recommended over something like (type(1) is int). Because isinstance will also return True if the object is an instance of a subclass.
def __init__(self):
pass