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
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4