[pypy-dev] Adding init/variables to W_Root

Carl Friedrich Bolz cfbolz at gmx.de
Fri Dec 16 17:20:34 EST 2016


Hi Frank, 

Yes, you'll get an instance variable that way. 

Cheers, 
Carl Friedrich

On December 16, 2016 6:05:56 PM GMT+01:00, Frank Wang <frankw at mit.edu> wrote:
>Hi Armin,
>
>Thanks for the suggestion! I'll see if that works. Just to make sure.
>This
>will give me an instance variable? I need values of the extra dict to
>be
>different for different instantiations of W_Root.
>
>Frank
>
>On Fri, Dec 16, 2016 at 11:19 AM, Armin Rigo <armin.rigo at gmail.com>
>wrote:
>
>> Hi Frank,
>>
>> On 15 December 2016 at 21:06, Frank Wang <frankw at mit.edu> wrote:
>> > Right now, I know W_Root has no __init__ function, and when I try
>to add
>> > one. I run into all sorts of problems because TypeDef calls
>> W_Root.__new__
>> > with some parameters, but "new" function seems to be called nowhere
>else.
>>
>> I suspect there is no clean way to add a __init__() method to W_Root.
>> You could use default attributes instead:
>>
>> class W_Root:
>>     _my_extra_dict = None
>>
>>     def get_extra_dict(self):
>>         if self._my_extra_dict is None:
>>             self._my_extra_dict = {}
>>         return self._my_extra_dict
>>
>>
>>
>> A bientôt,
>>
>> Armin.
>>
>
>
>------------------------------------------------------------------------
>
>_______________________________________________
>pypy-dev mailing list
>pypy-dev at python.org
>https://mail.python.org/mailman/listinfo/pypy-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20161216/5997aa3b/attachment.html>


More information about the pypy-dev mailing list