calling a variable from a separate function 
Author Message
 calling a variable from a separate function

Let's say

def function1:
     self.variable1 = 22
def function2:
     print variable1

Would function2 look like "print function1.variable1" or some other
way? By the way I already know that the "function1.variable1" format
doesn't work. thanks for any help.



Fri, 26 Dec 2003 09:52:21 GMT  
 calling a variable from a separate function
Well, I'm going to guess you mean to be working in a class.  Then what you'd
say is:

class Test:        #--untested--
    def func1(self):
        self.var1 = 22
    def func2(self):
        print self.var1

HTH,

--

Emile van Sebille

---------

Quote:
> Let's say

> def function1:
>      self.variable1 = 22
> def function2:
>      print variable1

> Would function2 look like "print function1.variable1" or some other
> way? By the way I already know that the "function1.variable1" format
> doesn't work. thanks for any help.



Fri, 26 Dec 2003 10:43:31 GMT  
 calling a variable from a separate function
Quote:

> Let's say

> def function1:
>      self.variable1 = 22
> def function2:
>      print variable1

> Would function2 look like "print function1.variable1" or some other
> way? By the way I already know that the "function1.variable1" format
> doesn't work. thanks for any help.

class a:
  v = 22

def b():
  print v



Mon, 05 Jan 2004 17:18:04 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. indirect function calls and variable variables

2. indirect function calls and variable variables

3. VC++ calling fortran function and fortran function calling a c++ function

4. How to find out name of calling function from called function

5. calling function recursively, local variables?

6. Local variables, call-back functions under Windows

7. evaluating a variable as a function call?

8. Function call or variable?

9. Function call or variable?

10. Call a function using a variable

11. How update variable values by calling secondary functions ?

12. variable function call

 

 
Powered by phpBB® Forum Software