Tagged Questions
0
votes
1answer
23 views
SWIG c++ python constructor wrong type (possible namespace issue)
I have a class that is implemented entirely in a header file (HKnotVector.h). I also have a SWIG interface file (HKnotVector.i) that defines some std_vector.i typemaps. There are definitions ...
0
votes
0answers
35 views
A better way to handle Python namespaces?
This question may be pretty elementary, but here goes:
I'm writing an app that will need lots of classes. I want to basically bundle these classes in to groups. To do that I am basically creating ...
0
votes
0answers
24 views
Appengine - Global namespaces for users and joining between different namespaces
I would like to use different namespaces in my google app engine app:
Users are in the default namespace (for login, then the namespace of user's company is picked)
Objects are in different ...
0
votes
1answer
31 views
How to reference an exception class in Python?
I want to catch a GPSException thrown by the gpxpy library.
try:
gpx = gpxpy.parse(open(filepath))
except GPXException:
print "GPXException for %s." % filepath
Since I am new to Python I do ...
0
votes
3answers
22 views
UnboundLocalError when using module inside a function?
When importing from the string module, to use with a parsing function.
from string import punctuation
def parsing_func(data):
if not any(i==v for i in data for v in punctuation.replace('_', ...
0
votes
1answer
26 views
Adding variables “by name” to local namespace
I know that I can add a variable to the global namespace "by name" with something like:
def getNewVar(name,val):
globals()[name]=val
The things is, I would like to do this in a local namespace. ...
0
votes
2answers
67 views
Python - Visibility of global variables from imported modules
I've run into a bit of a wall importing modules in a Python script. I'll do my best to describe the error, why I run into it, and why I'm tying this particular approach to solve my problem (which I ...
0
votes
1answer
20 views
Printing Parameter Values returning Unexpected Result, Python
I have the following python script snidbit:
inLines = sys.argv[0]
arcpy.AddMessage(inLines)
The input parameter is a multivalue input whereby the user can navigate to a file locations and choose ...
1
vote
4answers
71 views
Python: Namespaces with Module Imports
I am learning Python and am still a beginner, although I have been studying it for about a year now. I am trying to write a module of functions which is called within a main module. Each of the ...
0
votes
1answer
35 views
setting GAE namespace
This function works fine on Interactive console:
from google.appengine.api import namespace_manager
from google.appengine.ext import db
namespace_manager.set_namespace("some_namespace")
class ...
0
votes
0answers
18 views
Expose imported modules when importing a custom module
If I create a custom module, Foo, that imports a separate module Bar, I would like for the file that imports Foo to also be able to reference Bar directly as if it were imported into its local ...
1
vote
0answers
30 views
List modules in namespace package
I'm trying to get Python to list all modules in a namespace package.
I have the following file structure:
cwd
|--a
| `--ns
| |--__init__.py
| `--amod.py
|--b
| `--ns
| |--__init__.py
| ...
0
votes
0answers
47 views
Sharing pyserial serial object using multiprocessing manager namespace
Is it possible to share serial.Serial object between processes?
Maybe anybody can suggest any usefull aproach?
The sample code will show the problem:
from time import sleep
from multiprocessing ...
1
vote
0answers
45 views
How to access same multiprocessing namespace from different modules
I need to be able to create shared object with pySerial object in it. This object will be created by child process only once after finding device from list of locations. Other processes will use it in ...
0
votes
1answer
44 views
Is there a way to bypass the namespace/module name in Python?
If you have a module like module, can you bypass it and use the functions available inside without using the module?
I imported the module, but the compiler still complains not having to find ...
9
votes
3answers
73 views
Reversing from module import *
I have a codebase where I'm cleaning up some messy decisions by the previous developer. Frequently, he has done something like:
from scipy import *
from numpy import *
...This, of course, pollutes ...
1
vote
1answer
69 views
How to pass on argparse argument to function as kwargs?
I have a class defined as follows
class M(object):
def __init__(self, **kwargs):
...do_something
and I have the result of argparse.parse_args(), for example:
> args = parse_args()
...
-1
votes
2answers
63 views
Namespace of a Django web app during runtime
Edit: the question contains some misunderstandings. They will be fixed.
What happens to the Namespace of a Django web app after the server gets started?
In specific, what is stored in its "global" ...
1
vote
1answer
74 views
Python C-ext namespace mixed with regular python submodules?
This question has some resemblance with:
Nested Python C Extensions/Modules?
Only with a slight twist. Here I'm not trying to mix two C-exts, but one C-ext and a regular python submodule instead.
...
0
votes
3answers
53 views
python namespace: __main__.Class not isinstance of package.Class
Consider you have two python files as defined below. Say one is a general package (class2), and the other one does specific overrides and serves as the executable (class1).
class1.py:
...
0
votes
3answers
96 views
How to initialize a python object once and share across other modules?
For the life of me I am finding me python transition to be extremely frustrating. One of the things I am attempting at doing is to initialize a single instance of a class from a configuration ...
1
vote
1answer
76 views
Iterate through a Namespace
I have got a namespace looking like this :
Namespace(aTQ=None, bE=None, bEQ=None, b=None, bQ=None, c=None,
c=None, cJ=None, d=None, g=None, jR=['xx', '015'], lC=None, l=None)
How can I iterate ...
0
votes
2answers
96 views
Importing variables from a namespace object in Python
Say I have a namespace args that I obtain from calling parser.parse_args(), which parses the command line arguments.
How can I import all variables from this namespace to my current namespace?
e.g.
...
1
vote
1answer
53 views
Python: Run The Same Unittest module Tests For Multiple Files
I am attempting to create a simple framework that will discover all of the test cases from a specific directory (I am using unittest for these cases) and run each of these test cases against multiples ...
0
votes
1answer
64 views
How to avoid module name collision inside package context in python (without renaming)? [duplicate]
Possible Duplicate:
Python modules with identical names (i.e., reusing standard module names in packages)
From a module inside a package, is there a way to ignore package context for a ...
0
votes
2answers
48 views
changing namespace of current python script (class with module name)
i have a 2.6 python script and library in the following directory structure:
+ bin
\- foo.py
+ lib
\+ foo
\- bar.py
i would like users to run bin/foo.py to instantiate the classes within ...
3
votes
3answers
82 views
Python: possible to call static method from within class without qualifying the name
This is annoying:
class MyClass:
@staticmethod
def foo():
print "hi"
@staticmethod
def bar():
MyClass.foo()
Is there a way to make this work without naming MyClass ...
0
votes
1answer
73 views
Namespaces within a Python Class
I have this:
class MyClass:
"""A simple example class"""
i = 12345
def f(self):
print i # self.i will work just fine
return 'hello world'
When I do:
...
1
vote
2answers
67 views
Can I use (mis-use) the globals() namespace for persistent storage?
I'm writing some utilities that I want to call as functions. They are called with a context which tends not to change, and some data. There is a lot of time consuming fooing to be done with the ...
0
votes
1answer
42 views
How to access an upstream (namespace) module instance details without knowing if it exists?
Answer Credit to Leenert Regebro:
Apparently my instincts were right, and this is impossible. And obvious as well since there was only one answer in two hours.
Thanks for all the coments as well.
My ...