On Apr 5, 3:19 am, "sairam" <[EMAIL PROTECTED]> wrote:
> I have some local variables defined in one method and Can I make those
> variables as global variables? If so , can any one explain me how can
> I do that
>
> Thanks,
> Sairam
-----------
num = None
def f1():
global num
num = 30
def f2():
print num
f1()
f2()
-----------
You can read from a global variable, but to assign to one, you have to
declare its name in a global statement on the first line of the
function.
A better way:
------------
def f1():
num = 30
return num
def f2(x):
print x
result = f1()
f2(result)
-----------
--
http://mail.python.org/mailman/listinfo/python-list