Re: [Python-ideas] Allow function to return multiple values

joannah nanjekye wrote:
It was quite puzzling at first what was the actual idea but probably I can guess why this question came up by you. It seems to me (I am just intuitively guessing that) that you were about to write a procedure which operates on global variables. If so you should use the keyword "global" for that. E.g. if you want to work with the variables defined in other part of the code you can simply do it: x = 0 y = 0 def move(): global x, y x = x + 10 y = y + 20 move() print (x,y) This function will change x and y (global variables in this case). Note that without the line with the "global" statement this will not work. Another typical usage is initialising variables inside a procedure: def init_coordinates(): global x,y x=0 y=0 init_coordinates() print (x,y) So for some reason it seemed to me that you are trying to do something like that.
So if using globals as in the above examples you certinly don't have to suffer going around a tuple. Mikhail
participants (1)
-
Mikhail V