anything like C++ references?

Aahz aahz at
Sun Jul 13 19:40:13 CEST 2003

In article <13t0hvsb7idh0g6ac3upe5k0qd6flc17ah at>,
Tom Plunket  <tomas at> wrote:
>I want to do something along the lines of the following C++ code:
>void change(int& i)
>   i++;

class Counter:
    def __init__(self, start=0):
        self.counter = start
    def inc(self, increment=1):
        self.counter += increment

def change(counter):

There's no need to get into all the special methods required to
implement a number type, and it's a Bad Idea to use a random container
object.  Just pass around a mutable class instance, and your code
becomes simpler and clearer.
Aahz (aahz at           <*>

"Not everything in life has a clue in front of it...."  --JMS

More information about the Python-list mailing list