anything like C++ references?

Tom Plunket tomas at fancy.org
Sun Jul 13 03:41:22 EDT 2003


Dave Brueck wrote:

> Your response above (that the normal thing to do in Python is 
> just return the modified value) made me wonder if most people are 
> asking about pass-by-reference not because they want pass-by- 
> reference, but because in C it's generally a nuisance to return 
> stuff from functions, especially multiple values, so you end up 
> learning about pointers and/or pass-by-reference.

In C++ it's trivial to return multiple values and pass-by-
reference is typically (at least, as far as I've seen) used to
pass immutables anyway, but sometimes it just seems like the
right tool for the job.

> IOW, if you could erase the influence of previous languages would 
> this FAQ become "how can I return multiple things from a 
> function" more often than it would become "how can I modify an 
> object from inside a function"?

That's a good idea, although I would have to say that multiple
return values typically means that your function is doing too
many things.  ;)

-tom!




More information about the Python-list mailing list