Re: [Python-Dev] [Python-3000] in-out parameters
30 Apr
2006
30 Apr
'06
5:30 p.m.
Rudy Rudolph wrote:
2) pass-by-reference: def f(wrappedParam): wrappedParam[0] += 5 # ugh return "this is my result"
# call it x = 2 result = f([x]) # also ugly, but x is now 7
This example is broken; here's what you get when you run it:
def f(wrappedParam): ... wrappedParam[0] += 5 ... return "this is my result" ... # call it ... x = 2 result = f([x]) x 2
You probably intended something more like:
x = [2] result = f(x) x[0] 7
(As for the actual topic, I'm personally -0 for adding in-out parameters to python.) -Edward
6570
Age (days ago)
6570
Last active (days ago)
0 comments
1 participants
participants (1)
-
Edward Loper