All Questions
76
questions
-1
votes
1
answer
107
views
How do you get all the classes in another package so they can be instantiated in Python3?
I read the question "Importing a whole folder of python files", but it does not include a way to do it without one import per file.
Beside the requirement of avoiding several imports, it is ...
1
vote
1
answer
82
views
Not Defined Error when trying to use global Variables with Pandas at Module Level
I'm trying to make a data frame object global and i'm running into trouble and I'm not sure why. I have this across 2 files: main.py and helperFunction.py
it comes down to this format
helperFunction....
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/...
1
vote
1
answer
60
views
I want to import a Python3 function from a different folder with GLOBAL scope
I am working in Python3.x on Linux Mint 21 and here is my directory structure:
└── main_dir/
├── all_files_dir/
│ ├── a_files_dir/
│ │ └── file_a.py
│ ├── b_files_dir/
│ │...
0
votes
2
answers
60
views
Why global value doesn't change when reading from another module?
I have three files:
globals.py:
value = None
reader.py:
from globals import *
def read_global():
print(value)
changer.py:
from globals import *
from reader import *
def change_global():
...
1
vote
0
answers
76
views
Same global accessed via module or folder module have inconsistent values
I'm having trouble understanding the scope of global variables in python.
Maybe it's something wrong with the module or something wrong the way I'm using the global variable.
I have a global variable, ...
1
vote
2
answers
461
views
how to pass around global variable in python modules?
I would like to pass around a global variable in python. I know this is not an advisable method, but this belongs to a bigger application where I need to do this.
this is my main.py
from allfiles....
0
votes
3
answers
40
views
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 ...
0
votes
1
answer
79
views
How to make the export functions global after an import() call in JavaScript
So we have this function in JavaScript:
// main.js
import('./module.js');
Then we have the module file:
// module.js
export function SomeFunctionA() {
}
export function SomeFunctionB() {
}
Is it ...
1
vote
1
answer
817
views
How to properly export globals in Python modules?
I'm seeing this strange behavior with a module, which only happens if the module is implemented using an __init__.py and another file, containing the 'guts' of the module. So, let's say, I have a ...
-1
votes
1
answer
56
views
Is the global name 'a' in the same namespace as the module?
import math
a = 1
def my_func():
print('don\'t downvote')
my_func()
I believe that the function invocation my_func( ) lies in the local namespace created for the function my_func( ) - ready ...
0
votes
0
answers
50
views
What is module.globals?
Javascript modules have a module object which has well known property like module.exports which let us import functions and variables from a module.
However this object has few more properties such ...
0
votes
1
answer
219
views
Python: is there an equivalent to logging.getLogger(__name__) for argparse's parsers to pass args between modules?
The logging library allows us to define a global logger that can be accessed from any imported modules, like so:
main_script.py:
import logging
import module.py
if __name__ == "__main__":
...
1
vote
1
answer
1k
views
Python true global variables (python 3.7.0)
I know you can use the global keyword. But that's not...global. It's just a way to reference another variable outside of this function. If you have one variable that you want to reference it's no big ...
0
votes
1
answer
2k
views
Python 3 and global variable in module [duplicate]
main1.py
import mya
a=10
mya.increment_a()
a=a-5
print(a)
module mya.py
def increment_a():
global a
a=a+1
print(a)
name 'a' is not defined.
I don't understand why. I declare variable ...