newbie questions

Steve Holden steve at
Sun Dec 12 23:00:46 CET 2004

houbahop wrote:

> Thank you everyone, but I still not understand why such a comon feature like 
> passing parameters byref that is present in most serious programming
> languages is not possible in a clean way,here in python.
> I have the habit to never use globals as far as possible and this involve 
> that my main function is passing some parameters by reference to subs to 
> allow them to modify the vars.
> I would be sad to break my structured programming scheme because a lack of 
> feature.
> In others languages you can use things like pointers to strings or 
> Mysub(byref MyVar) ....
> and it does the trick :) 
The Python language allows complex objects to be returned, so there are 
two techniques you should be aware of.

1. If an argument is mutable (such as a list or a dictionary) then its 
contents can be modified using the reference passed in as an argument.

2. If an argument is immutable then it can be modified by returning the 
new value as a tuple element, in this way:

     a, b, c = someFunc(a, b, c)

Holden Web LLC +1 800 494 3119

More information about the Python-list mailing list