does Python support some kind of "casting"

Tino Lange tl_news at nexgo.de
Thu Mar 14 07:54:22 EST 2002


Hi!

Some days ago I posted two questions here in one message. The first was 
answered, the other not - maybe because the "Subject" line of the Message 
was related to the first question....

Here's my other question again - with an appropiate "Subject" line in the 
Header.

I'm playing with the new 2.2-feature of subclassing builtin types.
Especially I built an "MaxSizedList" that is a list, but it cannot grow 
over a maximum size. It throws the first elements away if new elements are 
appended.

Now I wanted to transfer the MaxSizedList on request via XML-RPC. But 
xmlrpclib only knows about "real" lists, not subclassed lists. And there 
seems to be no interface to add dump()-Methods for other data types, or?

So the best solution is to transport an object like
return list(newlist)

But I guess this makes a temporary copy of my MaxSizedList just for the 
XML-RPC-transport, or? So it's horrible inefficient? 

Is there no other way to deal with subclassed types in this lib besides 
patching the xmlrpclib to know my MaxSizedList? Is there a kind of casting 
to a "normal" list possible without making a completely new list from the 
MaxSizedList-Content?

Thanks a lot for your help!

Tino



More information about the Python-list mailing list