tags:

views:

68

answers:

2

can i do this?

var1 = some_function(var1)

when i tried to do this i got errors, but perhaps i was doing something wrong

thank you

+2  A: 
def myfun(param):
    return param * 2

y = 4
y = myfun(y)
print (y)

Works fine. prints 8;

So you could describe better the problem you're experiencing, preferably with full error traceback and source code I can run to reproduce the problem.

nosklo
+7  A: 

If the variable has been previously defined, you can do that yes.

Example:

def f(x):
    return x+1

var1 = 5
var1 = f(var1)
# var1 is now 6

If the variable has not been defined previously, you can't do that, simply because there is no value that could be passed to the function.

sepp2k