Questions tagged [global]
Refers to a space where variables and other items may be accessed from any scope.
4,545
questions
-4
votes
0
answers
24
views
Python globals() - how do variables get added/ updated to this global dictionary in the below example? [closed]
In this line, how does name get populated to the global_dict dictionary?
Method gets invoked here
0
votes
1
answer
42
views
Global FormClosing/Load events in .NET
I'm using VB.NET 4.7.2
I have a multi-form application and I'm coding the "Window" menu on top to show open forms so the user can easily switch (now that Win11 has forced combining ...
0
votes
2
answers
45
views
Tkinter: Global in function does not seem to work on button click
I want the var state to be True after clicking the button.
This is the code
from tkinter import *
root = Tk()
def value():
global state
state = True
print(state)
...
2
votes
1
answer
23
views
Dundered global variable cannot be accessed inside a class method
I am experiencing an obscure (to me) effect of dundered scoping, and trying to work out the rule for it:
#!/usr/bin/env python3
stuff = "the things"
__MORE_STUFF = "even more"
...
0
votes
2
answers
31
views
Python Tkinter Problem (with global keyword)
I have given two files in Python:
file1.py:
from file2 import *
root = None
create_window_middle(400, 400)
label1 = tk.Label(root, text="Label 1")
label1.pack()
label2 = tk.Label(root, ...
0
votes
2
answers
44
views
Laravel Server Side Event update global variable
I have an SSE event that selects last updates from table 'Newz' ad uses them to select from concerned tables the full data to stream it within the event.
The problem is I start with a global '$lastrec'...
0
votes
0
answers
6
views
c# global keyboard hook with Microsoft.Office.Interop.PowerPoint COMException
I'm using the full class provided as best answer in: C# Hook Global Keyboard Events - .net 4.0 without any changes to it. However, when pressing a key when focussed on the powerpoint, I get the ...
0
votes
2
answers
25
views
How to store fetched data from API to Global Variable
As seen in this picture, I have initialized variable madhu globally and assigning the fetched data to this variable inside .then method but it's showing me undefined.
How can I store this value ...
0
votes
0
answers
61
views
Contents of a vector get deleted after every loop iteration
I found out from another thread that apparently the objects defined within a specific iteration of a loop get deleted after the iteration is over. Hence I ran into a problem when I delete an element ...
0
votes
1
answer
58
views
Are there any tricks I can use to initialize global constants with a separate function call?
I have a lot of global settings defining the behavior of my program. I found it convenient to declare these settings as extern constants in a separate namespace like this:
// settings.hpp
namespace ...
-2
votes
3
answers
38
views
How can I refer to variable as global in python
I was define a global variables which I wanted to change / give an actual value in a function.
When I tried to run it, I had an error message that informing the global variable is undefined.
please ...
0
votes
1
answer
40
views
How to use global variables in nestjs
I want to use specific data as a global variable.
I thought about inserted it in the DataBase, but I thought it would be used too often, so I decided to leave it as a global variable.
However, I can't ...
1
vote
0
answers
42
views
How to determine in Clang API if a reference is to a global?
Using the Clang Python API I am trying to figure out if a reference to a C identifier is to a global definition - i.e. the scope of the identifier is more than to just a single file or sub-part ...
0
votes
1
answer
35
views
Array in Struct Pointer Only Updates Locally
I am trying to implement a very basic physics system, specifically gravity, in C. I have structured the individual components as follows:
typedef struct Gravity {
float force[2];
} Gravity;
typedef ...
-2
votes
1
answer
43
views
Global Constants in Python3 [closed]
I have some code which was written in Python2.7 and I need to convert it to Python3. My problem is that I used this
https://code.activestate.com/recipes/65207-constants-in-python/
to create a ...
0
votes
0
answers
25
views
delete a button from a different function (python tkinter)
I am writing a snake program which has a leaderboard built in. When someone clicks the leaderboard button, I would want my program to delete everything in the canvas (including the play_again and die ...
0
votes
1
answer
51
views
Global or local when creating a function
Hey I'm trying to write a basic assembler it doesn't even do real machine language,
the premise is to learn how to code in c ansi 90.
I have made a function that gets a string that supposedly has an ...
0
votes
1
answer
19
views
Exporting a global map from google earth engine
How does one export a global map from Google Earth Engine. I tried setting the bounding box to the following coordinates -180, -90, 180, 90 and what I get is a single column of data. I need these data ...
-1
votes
0
answers
41
views
Don't understand cause of this unassigned variable error message
I'm getting this issue in my app: UnboundLocalError: local variable 'myvariable' referenced before assignment.
def function1():
global franchise
franchise = txtFranchise.get().lower().replace(&...
0
votes
1
answer
38
views
local variable gives "stack smashing detected error" but global variable doesnt [duplicate]
int main(){
char x[] = "123";
srand(time(NULL));
scanf("%s", x);
printf("%s\n", x);
// run();
return 0;
}
But when I make x a global variable it works just fine. Is ...
0
votes
0
answers
15
views
How do I avoid using Global when using a variable in a different function?
I am building a sort of Road Code Quiz type of program that uses the user's inputs across multiple functions.
I established the variable usernote equal to NONE in my main routine, set it as global in ...
-1
votes
1
answer
53
views
Why doesn't this simple Python script run?
I am writing a large program where I need to pass data/variables between functions. Note: I'm a hobbyist and OOP is out of my grasp, so just looking for a non-OOP answer!
I'm using functions to try ...
0
votes
0
answers
20
views
In android how do I change activity from a global function?
I have a global functions class and one function i am writing checks the validity of the session by comparing the session and user id from localstorage to the database value and when it is invalid i ...
0
votes
0
answers
22
views
How to return a value from a closure function which returns itself?
How to return the variables "OurMin" and "counter" without passing by a global variable declaration like below, from a curried function which returns itself ?
"use strict&...
0
votes
0
answers
39
views
Global fit coupled odes system lmfit
I'm trying to get the global fit of multiple set of data considering a system of 4 coupled ODEs.
I have the working code that solves the system of 4 coupled ODEs for a single set of data, and I have ...
0
votes
0
answers
18
views
Manipulating variables using globals() in python
I wanted to have the option to pass my arguments to a function in a concise manner. So instead of passing all arguments directly, I include them as parameters function definiton and pass all such ...
0
votes
0
answers
49
views
How to Share Complex Custom Object for Multiprocessing and / or Flask
The main manager of my application must run permanently to regularly calculate new outputs, which are based on sensor data and afterwards partially emitted to a low number of clients via a web socket (...
0
votes
3
answers
58
views
Global value doesn't change in python
The point is that the global value doesn't change to False (enemy_1_alive).
enemy_1_alive = True
enemy_1_reward = 2000
enemy_2_alive = True
enemy_2_reward = 3000
...
def mission(alive, reward):
...
1
vote
0
answers
46
views
TS - how to declare global types correctly
I have an issue with the reference to a global type
In this project, window.app is a generic container that will get filled in runtime by individually lazy loaded self-invoking scripts.
This is the ...
0
votes
1
answer
48
views
Pyomo glpk solver doesn't give me the optimum
I hope someone can help me. I am practicing with optimization modelling and I am solving the following LP problem using pyomo glpk:
max z = 4x1 + 3x2
Subject to:
x1 + x2 <= 40
2x1 + x2 <= 60
x1,...
0
votes
1
answer
32
views
Python - global variable inside a while loop
I have this code, where:
last_price - is a variable that gets data from a price feed.
the code, does not work as intended. it shows this output "2 test line Y", but it should show 'test line ...
0
votes
1
answer
49
views
How to access variables in a function, where are they stored in memory
Hey where doe Python store variables in a function and how do i access them
Lets say i have the following code:
import ctypes
def reveal():
me = "where"
print(id(me))
reveal() # ...
0
votes
0
answers
43
views
Local variables diagnosis [duplicate]
I was wondering if there is a keyword for diagnosing local variables like global variables.
Here is my code:
t1 = "sweet"
def tastes():
global t1
t2 = "bitter"
t1 = t1 ...
0
votes
2
answers
43
views
Is it possible to take the Local Variable of a Function and convert it to a Global Variable or use it in an other Function
I'd like to know, If I can use the Local Variable of a Function (I'll call it for now Fct.1) in an other Function (Fct.2) (so that a variable in Fct.2 is assgined the same value of a Variable in Fct.1)...
0
votes
0
answers
24
views
how to use exec() to alter global and/or local variables inside a function
I did not understand how to properly use the global and local arguments of the exec() function. Actually, I need to use exec to alter either local or global variables. I got to write global variables, ...
3
votes
1
answer
72
views
Are globals considered statements?
This might be a simple question, but are globals, and anything written outside of a function (structs, enums, functions...), considered statements? If so, are all of them statements, or only some of ...
0
votes
1
answer
41
views
Global functions in Symphony application
I thought this would be easy. For troubleshooting, I wish to call my _logger() function from anywhere in my application.
function _logger(?string $msg=null, int $offset=0, bool $time=false):void
{
...
3
votes
2
answers
76
views
Global variable in Julia makes code an order of magnitude slower
I have the following code that runs in about 8 seconds:
using Random
DEBUG = false
PRISONERS = 100
ATTEMPTS = 50
function tryit()
a = [1:1:PRISONERS;]
a = shuffle(a)
for i in 1:PRISONERS
...
-1
votes
1
answer
38
views
How to pass the language information between actions? [duplicate]
Similar questions exists - I've tried already some solutions from StackOverflow and Google but still no luck - I can't catch a right syntax or right understanding - so let me repeat my question with ...
0
votes
0
answers
30
views
How to set global variables for UserForms in Excel VBA?
I made a module in Excel VBA that takes a large sum of data, asks the user which columns to plot, then plots it. I wanted to try and turn it GUI based so that the user doesn't have to memorize the ...
0
votes
0
answers
47
views
'@types/eslint@https://registry.npmjs.org/@types/eslint/-/eslint-8.4.4.tgz' is not in this registry [duplicate]
Whenever I try to install Webpack-cli with npm I get this error.
npm install -g webpack-cli
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@types/eslint/-/eslint-8.4.4.tgz -...
0
votes
1
answer
72
views
Tkinter global modules
Hello!
I've heard that the global function can lead to problems especially when debugging, so I'd like to know if anyone has an idea how to write the following python code the best way possible. ...
0
votes
1
answer
18
views
function executed by setInterval() multiple doesn't show results | Javascript
I am making a timer in javascript. But there is one thing I am not getting.
Here's the code...
var time = 0;
var timeInterval;
var testTime;
//Main code which increases the value of variable time by ...
0
votes
1
answer
35
views
Use a global state with Context
I'm currently trying to set a globalstate into my app. It's just about counting points, so a global "score".
Context seemed easy and I followed some tutorials, but it keeps sending errors.
...
-2
votes
1
answer
54
views
How to make an onclick event change a variable in the global scope?
I need to change a global variable through a click event, but it seems (I suspect) that it won't change that variable value outside the event. i'm looking for making some calculations based on local ...
2
votes
1
answer
57
views
How do i get a private vector while still using functions with openmp?
Im trying to parallelize my code with openmp.
I have a global vector, so i can excess it with my functions.
Is there a way that i can asign a copy of the vector to every thread so they can do stuff ...
0
votes
1
answer
61
views
Set global variables in function from dictionary [duplicate]
The problem:
I have a dictionary of keys and values:
param_dict = {
'VAR1' : 'abcd',
'VAR2' : (1, 1),
'VAR3' : 10.0
}
I want to write a function that takes in such a dictionary, and ...
0
votes
1
answer
23
views
Python change "globalish" variable inside a function
The following code
def myfunc():
x = ""
print("Python is " + x)
def hi():
global x
x = "OMG"
hi()
print("Python is " + x)
myfunc()
just ...
-1
votes
1
answer
43
views
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 = ...
0
votes
0
answers
17
views
I declared variable t1 outside the function but was able to use it without using global keyword but for counta and counto I have to use global why? [duplicate]
I declared variable t1 outside the function but was able to use it without using global keyword but for counta and counto I have to use global why?
While using counta and counto without global I'm ...