Re: Pointer variables possible?

Steven Miale (smiale@cs.indiana.edu)
Fri, 8 Apr 1994 14:02:07 -0500

In article <9404081624.AA01237@sparky.xvt.com.xvt.com>,
Consultant <amrit@xvt.com> wrote:
>You can use a list (clumsy but it works) to do the trick:

Here's an object-oriented approach that works much the same way...

-- Box.py --
class Box:
def __init__(self, value):
self.value=value
def get(self):
return self.value
def set(self,value):
self.value=value
def __repr__(self):
return 'Box(' + `self.value` + ')'
-- cut here --

>>> from Box import *
>>> x=Box(3)
>>> def makeitfour(foo):
... foo.set(4)
...
>>> makeitfour(x)
>>> x.get()
4
>>> x
Box(4)

-- 
Steven Miale - smiale@cs.indiana.edu | Don't blame me - 
Indiana University, Bloomington, IN  | I voted Libertarian.