Hey.

If at any place in code you want to call methods on a thing that can't
be proven to be of a specific subclass, they have to be defined on a
superclass (even dummy versions).

If you are however sure that this object will be of a specific subclass, write:
assert isinstance(x, MySubclass)
x.specific_method

that's fine

On Wed, Aug 4, 2010 at 10:21 AM, Hart's Antler <[email protected]> wrote:
> I'm still struggling to learn all the rules of RPython, i have read the 
> coding guide, and the PDF's PyGirl and Ancona's RPython paper, but still i 
> feel i'm not fully grasping everything.
>
> I have a function that returns different classes that all share a common base 
> class.  It works until i introduce a new subclass that has some methods of 
> the same name.  Then i get the demotion, can not follow, degenerated error.
>
> I googled, but all i can find is an IRC log where Fijal seems to taking 
> talking about my problem.
> http://www.tismer.com/pypy/irc-logs/pypy/%23pypy.log.20070125
>
> <fijal> pedronis: if function can return (in rpython) set of classes with 
> common superclass, than all methods that I call later must be defined on that 
> superclass, right?
>
> [11:30] <fijal> [15:01] <pedronis> yes, unless you assert a specific subclass
>
> So i just need to use an assert statement before the function return, and 
> assert the class i am returning?
>
> I am blogging about my progress while learning RPython, i have posted about 
> meta-programming in Rpython which is a new concept to me.
>
> http://pyppet.blogspot.com/2010/08/meta-programming-in-rpython.html
>
> -brett
>
>
>
> _______________________________________________
> [email protected]
> http://codespeak.net/mailman/listinfo/pypy-dev
>
_______________________________________________
[email protected]
http://codespeak.net/mailman/listinfo/pypy-dev

Reply via email to