types.AnyType - describing interfaces with sequences of types

Ixokai ixokai-nf at myNOSPAM.org
Thu Mar 29 05:34:24 EST 2001


The reason there is no UserType is because Types are the exclusive domain
of the C side of Python. Under normal circumstances, extentions/additions of
this nature in C end up making "types", while extentions/additions in Python
end up making Classes, which are not, under normal circumstances, able to
be made in C.

This is my understanding, at least. The missing behavior that you wish is a
result of the fact that Classes and Types really don't have that much in
common
yet... Sure, some types have wrappers around them, but there is no ultimate
ancestor that is available...

The problem is, I think, is that there really is no functionality to wrap in
a
'TypeType'. And until classes and types get all combined into the same
thing,
where you'd then have an ultimate ancestor to inherit from and compare to, I
don't think you'll get a way to do what you want exactly like you want.

Then again, I may be talking out of my ass. I'm a semi newbie who just lurks
forever. :)

--Ix

(Replace 'NOSPAM' with 'seraph' to respond in email)

Carlos Alberto Reis Ribeiro wrote in message ...
>At 02:56 28/03/01 -0800, you wrote:
>>You get the idea. AnyType above will be eternally happy to be equivelent
to
>>anything you compare it to. Note that you can't do 'IntType is AnyType',
>>that tells you actual object identity. Now, if you wanted it to only show
up
>>as 'equivelent' to TypeTypes, and not say, strings, (e.g. "string" ==
>>AnyType) you could do a check to make sure what its being compared to is a
>>TypeType.....
>
>My first instinct it was to do something like this. However, it did not
>work, but because of a dumb mistake of mine :-) I tried again now, and this
>is the resulting code:
>
>class CAnyType:
>   def __cmp__(self, other):
>         return (type(other) != TypeType)
>   def __rcmp__(self, other):
>         return (type(other) != TypeType)
>
>AnyType = CAnyType()
>
>That was my fault - I was trying to compare the class to IntType, but I
>need an instance for the code to work.
>
>Anyway, I felt that should be a better way to make it, maybe be inheriting
>from some "UserType" object. However no such object exists. I don't know if
>"UserType" does not exist because it not make sense, or if it does not
>exist simply because no one else required it before. The way it is, it's
>inconsistent, because:
>
> >>> type(AnyType)        # should return "TypeType"
><type 'instance'>
>
>
>
>Carlos Ribeiro
>
>
>




-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----



More information about the Python-list mailing list