Skip to content
Advertisement

Tag: global

Python local variable to global variable

I’m trying to write a modular script, with functions -Function 1 age = input(“tell me your age : “) -Function 2 weight = input(“tell me your weight : “) -Function 3 birthday = input(“tell me your birthday : “) at the end, i want to send a mail outside functions like : mail_body = age + weight + birthday Thanks

Get globals() dict from other module

I have follow this method to create a settings file with globals. settings.py I have : in main.py : I cannot see “test” in globals ! Any idea please ? Answer In Python, global variables are only global in the module where they were defined. If you want to access the global variables of an imported module, you can use:

Running functions siultaneoulsy in python

I am making a small program in which I need a few functions to check for something in the background. I used module threading and all those functions indeed run simultaneously and everything works perfectly until I start adding more functions. As the threading module makes new threads, they all stay within the same process, so when I add more,

Method of class in module doesn’t see my globals()

I have a problem with globals using method of class from my testmodule Example: Text of my test module: cat ./testmodule.py Text of my test class the same: Text of my test func, nothing new: And go to test it. Everything is ready, let’s test Variable exist The same result, variable exist Variable is lost. How can i get the

Global variables in recursion. Python

OK, i’m using Python 2.7.3 and here is my code: I’m trying to modify the variable count inside the leng function. Here are the things that I’ve tried: If I put the variable count outside the lenRecur function it works fine the first time, but if I try again without restarting python shell, the count (obviously) doesn’t restart, so it

Reason for globals() in Python?

What is the reason of having globals() function in Python? It only returns dictionary of global variables, which are already global, so they can be used anywhere… I’m asking only out of curiosity, trying to learn python. I can’t really see the point here? Only time I would need it, was if I had local and global variables, with same

Global static variables in Python

I need to use list data in other functions, but I don’t want to enter raw_input everytime. How I can make data like a global static in c++ and put it everywhere where it needed? Answer Add the global keyword to your function: The global data statement is a declaration that makes data a global variable. After calling Input() you

Advertisement