python2.2: type('name') -> <type 'str'> ??
Thomas Bellman
bellman at lysator.liu.se
Wed Jul 25 18:17:53 EDT 2001
"Tim Peters" <tim.one at home.com> wrote:
> C:\Code\descr\dist\src\PCbuild>python
> Python 2.2a1 (#21, Jul 21 2001, 01:12:35) [MSC 32 bit (Intel)] on win32
> ...
> >>> class C:
> ... pass
> ...
> >>> type(C())
> <type 'instance'>
> >>> type(C())()
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> TypeError: cannot create 'instance' instances
> >>>
I would seem logical to unify the instance type with the instance
function in the new module. So:
>>> import new
>>> type(C()) is new.instance
1
>>> type(C())(C, None)
<__main__.C instance at 0x120240af8>
And of course the same for classobj, function, module and code.
> it's-a-unification-not-a-miracle<wink>-ly y'rs - tim
--
Thomas Bellman, Lysator Computer Club, Linköping University, Sweden
"You cannot achieve the impossible without ! bellman @ lysator.liu.se
attempting the absurd." ! Make Love -- Nicht Wahr!
More information about the Python-list
mailing list