Questions tagged [global-variables]
Global variables are variables that are accessible from all elements of a software component.
global-variables
8,859
questions
-4
votes
1
answer
75
views
Python using variables in module [closed]
How to call variables declared in one file to another file?
Hi Everyone
I have declared my variable in file1. My function is in file2 which uses the variable. How do I call my variable which is ...
1
vote
1
answer
39
views
global-ish object groups in python
I need to keep track of groups of objects, which I want to access from anywhere in my code.
this is my 5 minute solution:
# this is in the __init__.py of the main directory of the package.
# I import ...
0
votes
0
answers
17
views
Exposing Global Variable In Vite
After hours of searching through the doc (Vite) I've realised there is no simple way to expose a global string variable accessible via window.MY_VARIABLE in the browser console. At least as I can see ...
1
vote
1
answer
156
views
Thread pool design
I have a design question about thread pool. Consider the following code:
int main() {
auto po = std::execution::par_unseq;
// If Parallel STL uses TBB as the backend, I think the thread pool
/...
0
votes
1
answer
53
views
C++ Global variables sticking to all boost unit tests once set
I am stuck trying to isolate my test cases in terms of global variables.
In my core.h,
int globalMethod(bool flag);
In my core.cpp,
#include "core.h"
bool globalVar = false;
int ...
2
votes
1
answer
35
views
xlwings not updating global variable correctly when using threading
Here is my logic that I am trying to understand.
import xlwings as xw
import threading
workbook = ""
def function1():
t1 = threading.Thread(target=function2)
t1.start()
t1.join()...
0
votes
1
answer
115
views
Two or more files get the same variable
As title.
I have variable file A,
global var = 0
program file B,
import A
for i in range(1000):
A.var += 1
time.sleep(1)
and program file C:
print(A.var)
Then,what can I do to let B or C ...
2
votes
2
answers
71
views
How to access global variable via JNA interface?
I need to access a "native" C library from Java via Java Native Access (JNA). The idiomatic way to do this seems to be defining an interface that extends Library and that declares all the ...
3
votes
1
answer
128
views
Is accessing a global `static` variable from a single TU guaranteed to be safe?
The SFML library initializes an audio device when the first object of type AudioResource is created, and deinitializes it when the last one is destroyed.
I am trying to simplify that code, as I ...
0
votes
0
answers
25
views
Setting global values using edge.js not working and displays undefined when tried to display in one of the templates
I am starting to learn Node JS. I am trying to set global values available to all templates using below code.
const express = require("express");
const expressEdge = require("express-...
0
votes
0
answers
26
views
How can I carry user login information from a landing page to the home page in React using Firebase as authentication?
I tried to add the user information (like email and photoURL) to an object but then I couldn't find a way to export it to the home page. I can access the user info locally but I can't use it in ...
0
votes
1
answer
21
views
TLE on coin combinations 1 cses
can someone tell why the following code for coin combinations 1 question from cses problemset is getting time limit exceeded
#include <bits/stdc++.h>
#define int long long
using namespace std;
...
-1
votes
1
answer
77
views
var vs let for *globals*... what practical difference does "a property on the global object" make?
I have seen this (or similar):
At the top level, let, unlike var, does not create a property on the
global object.
many times.
My question is: what practical difference does this make ?
Or, to put ...
0
votes
2
answers
58
views
Global associative array (hash) in the older bash-4
The following script works as expected for me on FreeBSD using bash-5:
function a {
declare -gA Seen
if [[ -v Seen[$1] ]]
then
echo "Saw $1 already"
return
...
1
vote
1
answer
39
views
Display product excerpt only when using WooCommerce product_category shortcode
I'm looking to use something like [product_category excerpt="yes"]
in order to display product short description only when needed.
I'm using this function below to add the product short ...