All Questions
289
questions
1
vote
1
answer
36
views
global variables get different values (web / terminal)
While learning php I came across the following problem.
I don’t understand why I get different values on my local site and in the terminal when I run the following code:
function scopeTest(): int
{...
0
votes
1
answer
49
views
Why do different delivery methods have different results when applying PHP's global keyword?
PHP implements the static and global modifier for variables in terms of references. For example, a true global variable imported inside a function scope with the global statement actually creates a ...
0
votes
0
answers
83
views
Global vs. local scope at `(new Function()).call(...)`
my Problem seems to be in my module.js.
It seems the evaluateJavaScript() function calls my script modules correctly:
the this in the module is a reference to the new Module() object (within Module....
1
vote
3
answers
414
views
Scope of a structure in C language
Could someone explain in simple terms what is meant by this?
The scope of a structure begins at its appearance in a type specifier, and persists to the end of the translation unit (for declarations ...
-2
votes
2
answers
109
views
Isn't this a proper global variable usage in python? It keeps on giving syntax error. What really is a global keyword usage [duplicate]
q=8
def example(q):
global q
q=q+2
print(q)
example()
File "<ipython-input-35-0e5cbb9ebefd>", line 2
global q
^
SyntaxError: name 'q' is parameter and global
...
0
votes
2
answers
66
views
PHP - Way to call a function that creates variables outside in calling context?
I'd like to pull all the names of fields from a submitted form, and create variables from them automatically. Not much of a problem as my code1 below shows. BUT I'd now like to put the code in a ...
1
vote
1
answer
212
views
Script Scope in JS
I was going through Lexical environment and environment record / scope in JS.
I know difference (partly) between var and let (one being block scoped, while one being functional scope) and also the let ...
1
vote
1
answer
64
views
Does python redefine guess of variable scope inside function?
I have a simple example that is confusing me, concerning local and global scopes in functions.
a=1
def func():
print(a) # Error: local variable 'a' referenced before assignment
a=2
print(...
1
vote
0
answers
27
views
Difference in scope between int and list in Python code [duplicate]
I have the following Python code snippet:
# code 1
# makes an error
def func1():
a += 1
a = 1
try:
func1()
print(a)
except UnboundLocalError as e:
print(e)
# code 2
# makes no ...
1
vote
1
answer
51
views
Function to exchange value between variables
I am trying to write a function that makes "transactions" between "adresses" (variables) by exchanging values between them. I want to make it so that I can just write the reciever ...
1
vote
1
answer
87
views
python - the scope of variables inside "main" function
This is my first post here, so please give me some constructive criticism (not too much).
My initial intent was to receive inputs from the user, and save them into variables to later user in other ...
0
votes
1
answer
31
views
Acessing for loop varible in another python script
I have the file name as file1.py the code is following.
`
import os
global x
def a_function():
while True:
for x in range(12):
cmd=f'rosbag record -O /home/mubashir/catkin_ws/...
0
votes
1
answer
91
views
how to change the scope for recursive asyncio functions
I have two async functions with local scope and one checking function with global scope. The two async functions reference each other (hence recursive behaviour).
All three functions are called from ...
-2
votes
1
answer
134
views
since in python we cannot pass by reference then how to change the value of variable present in other scope in python [duplicate]
I used two techniques just to tackle this problem but was unable to resolve it. I want to modify the value of 'a' from 5 to 6 here but it is not modifying.
def f2():
a=5
def insidefun(c):
...
0
votes
1
answer
97
views
How can I override global variables just for the scope of callees of a function in Python?
I'm writing a decorator which needs to pass data to other utility functions; something like:
STORE = []
def utility(message):
STORE.append(message)
def decorator(func):
def decorator_wrap(*args, *...