Is types.InstanceType no longer valid with Python 2.2

Skip Montanaro skip at pobox.com
Thu Jan 3 11:17:13 EST 2002


    Georg> after updating to Python 2.2 I've gotten some errors yielded by
    Georg> my lines:

    Georg> class foo:
    Georg>     pass

    Georg> ss = 'foo()'
    Georg> ff = eval(ss)
    Georg> assert(type(ff) == types.InstanceType)

    Georg> Because until version 2.1 of Python any instantiated object has
    Georg> its type 'instance', but with Python 2.2 this has been
    Georg> changed. 

Works for me:

    >>> class foo: pass
    ... 
    >>> ff = foo()
    >>> type(ff)
    <type 'instance'>
    >>> import types
    >>> type(ff) == types.InstanceType
    1
    >>> ss = 'foo()'
    >>> ff = eval(ss)
    >>> type(ff) == types.InstanceType
    1

Try pasting a simple interactive session or script (with output) that
demonstrates that this fails for you.

-- 
Skip Montanaro (skip at pobox.com - http://www.mojam.com/)




More information about the Python-list mailing list