chaouche yacine <yacinechaou...@yahoo.com> wrote:

> 
> booleans
> ints, floats, longs, complexes
> strings, unicode strings
> lists, tuples, dictionaries, dictionary views, sets, frozensets,
> buffers, bytearrays, slices functions, methods, code
> objects,modules,classes, instances, types, nulls (there is exactly one
> object of type Null which is None), tracebacks, frames generators,
> iterators, xranges, files,
> 
> memoryviews,
> context managers,
> 
> These are all listed in this page
> http://docs.python.org/2/library/stdtypes.html as built-in types. Am I
> getting anything wrong here ? I'm a bit confused about it. I have
> never seen so many types in the few programming languages I saw. 

Instances aren't types (though types themselves are instances): every 
object in Python is an instance.

If you want a list of types that exist in your particular copy of Python 
then you can print it out easily enough:

------------------------------------------------
def allsubclasses(base):
    mod = base.__module__
    if mod in ('builtins', '__builtin__', 'exceptions'):
        yield getattr(base, '__qualname__', base.__name__)
    else:
        yield "{}.{}".format(base.__module__, getattr(base, 
'__qualname__', base.__name__))
    for typ in type.__subclasses__(base):
        for t in allsubclasses(typ): yield t

all_types = sorted(set(allsubclasses(object)), key=str.lower)
print(len(all_types))
print(all_types)
------------------------------------------------

That won't show any types that haven't been imported, but it gives me  
293 types that are all loaded on startup in Python 3.3 and 150 in Python 
2.7.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to