I would simply subclass 'int', but this object needs to be general enough to pretend to be an 'int', 'NoneType', 'str', etc... A long shot: Can I change the base class on an instance by instance basis depending on the need? Well, now I can imagine having a class factory that will spawn for me the class that inherits the correct base type. Any other solutions?<br>
<br>Thanks Chris.<br><br><div class="gmail_quote">On Fri, Feb 6, 2009 at 3:42 AM, Chris Rebert <span dir="ltr"><<a href="mailto:clp2@rebertia.com">clp2@rebertia.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div class="Wj3C7c">On Fri, Feb 6, 2009 at 3:03 AM, Ken Elkabany <<a href="mailto:Ken@elkabany.com">Ken@elkabany.com</a>> wrote:<br>
> Hello,<br>
><br>
> I am attempting to fully-simulate an 'int' object with a custom object type.<br>
> It is part of a library I am creating for python futures and promises. Is<br>
> there anyway such that type(my_object) can return <type 'int'>? Or for that<br>
> matter, any other primitive? I do not care how dirty the solution might<br>
> possibly be; Could there be a way through the C API? Though I predict it<br>
> will cause a mess with the interpreter.<br>
<br>
</div></div>Any particular reason why subclassing 'int' wouldn't be good enough?<br>
(You did know you can do that, right?)<br>
I know you can subclass int at the Python level and I would think you<br>
should be able to do it at the C level also (if not, the design just<br>
gets only slightly more involved).<br>
<br>
Cheers,<br>
Chris<br>
<font color="#888888"><br>
--<br>
Follow the path of the Iguana...<br>
<a href="http://rebertia.com" target="_blank">http://rebertia.com</a><br>
</font></blockquote></div><br>