how to change a variable from a module inside a module in a module… (confused)



I have a variable in my main module which is changed using another module, but I want to change the variable from my main module through another module. I'm new to programmering, so I actually don't really know how to explain this stuff - sorry if I'm asking a stupid question.


The program's hierarchy looks a bit like this:


Main

---Features

---Pygame_handling

------Features


I use the "Features" module to change a variable in the "Main". I do this simply by getting the defined variable from "Features". But when I change the variable through "Pygame_handling", it is not changed in the "Features" object


Related to : how to change a variable from a module inside a module in a module… (confused)
ImportError: No module named … with external module on Windows 7
Programming Languages

I'm new to Python and am using it only to get a third-party module running. It's quite a specialized application (and available at https://github.com/patvarilly/DNACC) but I guess that my problem is more generic.


I installed Python 2.7.3 (32-bit) along with NumPy 1.6.1, SciPy 0.11.0 and Visual C++ 2008 Express on a Windows 7 64-bit system. I then unzipped DNACC into the site-packages subfolder and executed "setup.py install" from the DOS shell (as an Administrator). This is the error message I got in response:


Traceback (most recent call last):



File "C:Python27Libsite-packagesDNACC-mastersetup.py", line 166, in

Making all variables in a scope global or importing a module inside another module
Programming Languages

I have a package with two modules in it. One is the __init__ file, and the other is a separate part of the package. If I try from mypackage import separatepart, the code in the __init__ module is run, which will run unneeded code, slowing down the importing by a lot. The code in separate part won't cause any errors, and so users should be able to directly import it without importing the __init__ module.


Since I can't figure out a way to do this, I thought I should include a function in the __init__ file that does everything so nothing would be done directly, but in order to do this, I would need to have

Node.js: How can I use Commander.js inside my module while still allowing 3rd parties to use it when including my module
Programming Languages

I use Commander.js in my Node.js module, the problem I'm experiencing is when a 3rd party Node.js script includes my module and also wants to use Commander.js, my specified parameters show up but theirs don't. Is there a way that both of our parameters can work together?


The background story is I have a Node.js module that displays debug information to the user when they run their script, but when they run the script in production they don't want this information outputted so they run it with:


node script.js --production

How to change a module variable from another module?
Programming Languages

Suppose I have a package named bar, and it contains bar.py:


a = None
def foobar():
print a

and __init__.py:


from bar import a, foobar

Then I execute this script:


import bar
print bar.a
bar.a = 1
print bar.a
bar.foobar()

Here's what I expect:


None
1
1

Here's what I get:


None
1
None

Can anyone explain my misconception?


how to change a variable from a module inside a module in a module… (confused)
Programming Languages

I have a variable in my main module which is changed using another module, but I want to change the variable from my main module through another module. I'm new to programmering, so I actually don't really know how to explain this stuff - sorry if I'm asking a stupid question.


The program's hierarchy looks a bit like this:


Main

---Features

---Pygame_handling

------Features


I use the "Features" module to change a variable in the "Main". I do this simply by getting the defined variable from "Features". But when I change the variable through "Pygame_handling", it is not changed in the "Features" object

How do I import an external module when a local module masks a standard library module imported by the external module?
Programming Languages

I have a local module named tokenize.py, masks a standard library module of the same name. I only discovered this when I tried to import an external module (sklearn.linear_model), which in turn does import tokenize and expects to get the standard library module, but gets my local module instead.


This is related to How to access a standard-library module in Python when there is a local module with the same name?, but the setting is different, because applying the above solution would require modifying the external module.


An option would be to rename the local tokenize.py, but I would prefer not to do so as "tok


Privacy Policy - Copyrights Notice - Feedback - Report Violation - RSS 2017 © bighow.org All Rights Reserved .