Background
The algorithm manipulates financial analytics. There are multiple lists of the same size and they are filtered into other lists for analysis. I am doing the same filtering on different by parallel lists. I could set it up so that a1,b1,c2 occur as a tuple in a list but then the analytics have to stripe the tuples the other wa...
I need to do the following in Python. I want to spawn a process (subprocess module?), and:
if the process ends normally, to continue exactly from the moment it terminates;
if, otherwise, the process "gets stuck" and doesn't terminate within (say) one hour, to kill it and continue (possibly giving it another try, in a loop).
What is t...
I have fecora 11, set django with mod_wsgi2.5 and apache2.2. And I can run "python manage.py runserver" at local. It works fine. I got error when i test from remote browser.
Thanks for any suggestion and help!
...
I'm getting the following error when using the multiprocessing module within a python daemon process (using python-daemon):
Traceback (most recent call last):
File "/usr/local/lib/python2.6/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/usr/local/lib/python2.6/multiprocessing/util.py", line 262, in _exit_fu...
the following is a line from a python program that calls the "demo.exe" file. a window for demo.exe opens when it is called, is there any way for demo.exe to run in the "background"? that is, i don't want the window for it show, i just want demo.exe to run.
p = subprocess.Popen(args = "demo.exe", stdout = subprocess.PIPE)
the output ...
Him
I have a dictionary dict1['a'] = [ [1,2], [3,4] ]. I need to generate a list out of this dictionary as l1 = [2, 4] i.e., a list out of the second element of each inner list. It can be a separate list or even the dictionary can be modified as dict1['a'] = [2,4]. Any idea would be appreciated.
...
If I have a function (in Python 2.5.2) like:
def sample_func():
a = 78
b = range(5)
#c = a + b[2] - x
My questions are:
How to get the local variables (a,b) of the function from outside without using locals() inside the function? (kind of reflection)
Is it possible to set a local variable (say x) from outside so that the...
Is there a way to transfer a new class instance (python class that inherits c++ class) into c++ with out having to hold on to the object return and just treat it as a c++ pointer.
For example:
C++
object pyInstance = GetLocalDict()["makeNewGamePlay"]();
CGEPYGameMode* m_pGameMode = extract< CGEPYGameMode* >( pyInstance );
pyth:
cla...
How to generate a KeyboardInterrupt in Windows?
while True:
try:
print 'running'
except KeyboardInterrupt:
break
I expected CTRL+C to stop this program but it doesn't work.
...
thanks guys.i managed to complete it.million thanks again specially for DAVID,WM-EDDIE and S.LOTT.also STACKOVERFLOW
The solution:
**model = Contact()
model.contact_owner = request.user
model.contact_name = row[1]
model.contact_mobile_no = row[2]
model.sele...
Hi,
I have some data which look like that:
PMID- 19587274
OWN - NLM
DP - 2009 Jul 8
TI - Domain general mechanisms of perceptual decision making in human cortex.
PG - 8675-87
AB - To successfully interact with objects in the environment, sensory evidence must
be continuously acquired, interpreted, and used to guide appropriat...
Hello,
I'm creating a class, but having some trouble with the namespacing in python.
You can see the code below, and it mostly works ok, but after the call to guiFrame._stateMachine() the time module is somehow not defined anymore.
If I re-import the time module in _stateMachine() it works. But why is the time module not in the namesp...
Hi,
I have problem with HTTP headers, they're encoded in ASCII and I want to provided a view for downloading files that names can be non ASCII.
response['Content-Disposition'] = 'attachment; filename="%s"' % (vo.filename.encode("ASCII","replace"), )
I don't want to use static files serving for same issue with non ASCII file names but...
I am running a site where users can private message each other. As with any other such website, to read and mark their messages, users must log on to the site.
I wish to expose an IMAP interface so that users may read their site messages using their standard email client. There would be few complications in such approach as what be user...
Can someone help me to find solution on how to calculate cubic root of the negative number using python?
>>> math.pow(-3, float(1)/3)
nan
it does not work. Cubic root of the negative number is negative number. Any solutions?
...
I would like to use properties from an inheriting model's Meta class to configure a field defined in an abstract model higher up the inheritance tree:
class NamedModel(models.Model):
class Meta:
abstract = True
verbose_name = 'object'
name = models.CharField("Name",
max_length=200,
db_index=True,...
Hi (sorry for my ugly english)
I wonder if this is possible to retrieve an object which was selected with the object_detail generic view. For example :
from django.views.generic.list_detail import object_detail
def my_view(request, slug)
response = object_detail(request, MyModel.objects.all(),
slug=slug,
slug_fie...
I know this question is kind of stupid, maybe it's a just a part of writing code but it seems defining simple functions can really hurt performance severely... I've tried this simple test:
def make_legal_foo_string(x):
return "This is a foo string: " + str(x)
def sum_up_to(x):
return x*(x+1)/2
def foo(x):
return [make_lega...
I have a DLL containing a C function with a prototype like this:
int c_read_block(uint32 addr, uint32 *buf, uint32 num);
I want to call it from Python using ctypes. The function expects a pointer to a chunk of memory, into which it will write the results. I don't know how to construct and pass such a chunk of memory. The ctypes documen...
So I have a function in vb that is converted to a dll that I want to use in python. However trying to use it, I get an error message
this is the VB function
Function DISPLAYNAME(Name)
MsgBox ("Hello " & Name & "!")
End Function
and this is how I call it in python
from ctypes import *
test = windll.TestDLL
print test
print test.DISPL...