python - How to access a variable from one function in another -


i know may seem copy many other questions asked on stack overflow, didn't understand of questions. need clarify me, , please don't flag this. i'm running on python 3.4.2, windows 8.1

sample code:

def function_a():     my_name = "pamal mangat"     return my_name  def function_b(name):     print("hello " + name)  function_b(function_a.my_name) 

you need call function_a() way you're calling function_b(); that's how return value. can't access variables inside function that; besides, exist while function running.

def function_a():     my_name = "pamal mangat"     return my_name  def function_b(name):     print("hello " + name)  function_b(function_a()) 

Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

how to prompt save As Box in Excel Interlop c# MVC 4 -

xslt 1.0 - How to access or retrieve mets content of an item from another item? -