Tapping into the access of an int instance
Piet van Oostrum
piet at cs.uu.nl
Tue Oct 2 04:04:35 EDT 2007
>>>>> chris.monsanto at gmail.com (CM) wrote:
>CM> On Sep 20, 1:21 pm, "Tor Erik Sønvisen" <toreri... at gmail.com> wrote:
>>> Hi,
>>>
>>> Does anyone know how to interrupt the lookup of an integer value? I
>>> know I need to subclass int, since builtin types can't be altered
>>> directly...
>>>
>>> Below is how far I've come... What I want is to tap into the access of
>>> instance i's value 1...
>>>
>>> >>> class Int(int):
>>>
>>> def __init__(self, *a, **k):
>>> super(Int, self).__init__(self, *a, **k)
>>>
>>> >>> i = Int(1)
>>> >>> i
>>>
>>> 1
>>>
>>> Regards,
>>> Tor Erik
>CM> While I'm not *totally* sure what you are asking, you can access the
>CM> first parameter you passed in __init__ via args[0].
What args do you mean?
--
Piet van Oostrum <piet at cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4]
Private email: piet at vanoostrum.org
More information about the Python-list
mailing list