missing types in module types?

Discussion in 'Python' started by Manlio Perillo, May 29, 2004.

  1. Hi.

    I have found that some types are missing from module types:

    import types
    from types import *

    def check_type(obj):
    type_list = [eval(t) for t in dir(types) if t.endswith('Type')]
    return [[x, type(obj)] for x in type_list if isinstance(obj, x)]

    def fun(): pass

    cm = classmethod(fun)
    sm = staticmethod(fun)

    p = property()

    print check_type(cm)
    [[<type 'object'>, <type 'classmethod'>]]

    print check_type(sm)
    [[<type 'object'>, <type 'staticmethod'>]]

    print check_type(fun.__init__)
    [[<type 'object'>, <type 'method-wrapper'>]]

    print check_type(p)
    [[<type 'object'>, <type 'property'>]]

    Regards Manlio Perillo
    Manlio Perillo, May 29, 2004
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.