anything like C++ references?

Michael Hudson mwh at python.net
Mon Jul 14 06:32:01 EDT 2003


Stephen Horne <intentionally at blank.co.uk> writes:

> On Sun, 13 Jul 2003 05:50:46 -0600, Dave Brueck
> <dave at pythonapocrypha.com> wrote:
> 
> >But the method for returning more than one thing is not a simple progression 
> >from this pattern. Instead you learn and shift to a *completely* different 
> >mechanism. In Python, however, you *can* continue along the original route as 
> >well:
> >
> >def foo(a, b, c):
> >  return a+b, b+c
> 
> You are not directly returning multiple values - you are returning a
> tuple. You can return containers in C++ too. The only difference is
> that Python makes working with tuples *much* easier - but its no more
> a 'simple progression' than in C++. You still need to know about
> tuples as well as returning values.

Actually, at one stage in Python's development it was almost
completely symmetric: you (always) passed in a tuple, and could
optionally return a tuple.  The syntax made it look a bit like you
were passing in multiple arguments, but under the hood a tuple was
what you were passing, and there were ways in which this showed up.
IIRC, 

    f((a, b))

and 

    f(a, b)

were indistinguishable from inside f.  This was all long before I came
across python, so I may be getting things mixed up...

Cheers,
M.

-- 
  Roll on a game of competetive offence-taking.
                                            -- Dan Sheppard, ucam.chat




More information about the Python-list mailing list