I have a python script, which I daemonise using this code
def daemonise():
from os import fork, setsid, umask, dup2
from sys import stdin, stdout, stderr
if fork(): exit(0)
umask(0)
setsid()
if fork(): exit(0)
stdout.flush()
stder...
hello,
i have some form which split by iframe.
subject field is no probelm ,but content field was come from another iframe source..
so i can't input text in content's field..
im using PAMIE and win32com module..
i have to put text in 'contents.contentsValue' here.
but i have no luck..anyone can help me? if so really appreciate
follow is...
For an uncaught exception, Python by default prints a stack trace, the exception itself, and terminates. Is anybody aware of a way to tailor this behaviour on the program level (other than establishing my own global, catch-all exception handler), so that the stack trace is omitted? I would like to toggle in my app whether the stack trace...
Python doesn't allow dictionaries to be used as keys in other dictionaries. Is there a workaround for using non-nested dictionaries as keys?
The general problem with more complicated non-hashable objects and my specific use case has been moved here. My original description of my use case was incorrect.
...
Is there a way to use the setTrace() function in a script that has no method definitions? i.e.
for i in range(1, 100):
print i
def traceit(frame, event, arg):
if event == "line":
lineno = frame.f_lineno
print "line", lineno
return traceit
sys.settrace(traceit)
so ideally I would want the trace function to be...
Apologies for reposting but I had to edit this question when I got to work and realized I needed to have an account to do so. So here it goes again (with a little more context).
I'm trying to time how long a script takes to execute, and I am thinking of doing that by checking the elapsed time after every line of code is executed. I've d...
Have a look at this Python code:
a = [1, 2, 3]
b = [4, 5, 6]
c = [[a, b], [b, a]] # [[[1, 2, 3], [4, 5, 6]], [[4, 5, 6], [1, 2, 3]]]
c[0][0].append(99) # [[[1, 2, 3, 99], [4, 5, 6]], [[4, 5, 6], [1, 2, 3, 99]]]
Notice how modifying one element of c modifies that everywhere. That is, if 99 is appended to c[0][0], it is also appended ...
I'm using a config file to get the info for my database. It always gets the hostname and then figures out what database options to use from this config file. I want to be able to tell if I'm inside a unittest here and use the in memory sqlite database instead. Is there a way to tell at that point whether I'm inside a unittest, or will...
Pardon the excessive amount of code, but I'm not sure if I can explain my question otherwise
I have a Django project that I am working on which has the following:
class Project(models.Model):
name = models.CharField(max_length=100, unique=True)
dir = models.CharField(max_length=300, blank=True, unique=True )
def __unicode__(self):...
Hi,
I want to calculate a convex hull around a shape in a binary NxM matrix. The convex hull algorithm expects a list of coordinates, so I take numpy.argwhere(im) to have all shape point coordinates. However, most of those points are not contributing to the convex hull (they lie on the inside of the shape). Because convex hull computati...
If I want the access log for Cherrypy to only get to a fixed size, how would I go about using rotating log files?
I've already tried http://www.cherrypy.org/wiki/Logging, which seems out of date, or has information missing.
...
Hello,
I realize that this may sound like a silly question, but the last time I programmed it was in assembler so my thinking may be off:
A recursive function as so:
def fac(n):
if n == 0:
return 1
else:
return n * fac(n - 1)
Why is it that when the function reaches n == 0 that it does not return 1 but rather...
It seems that the software language skills most sought for embedded devices and robots are C, C++, and LISP. Why haven't more recent languages made inroads into these applications?
For example, Erlang would seem particularly well-suited to robotic applications, since it makes concurrent programming easier and allows hot swapping of co...
In python's tkinter interface, is there a configuration option that will change a Label such that you can select the text in the Label and then copy it to the clipboard?
EDIT:
How would you modify this "hello world" app to provide such functionality?
from Tkinter import *
master = Tk()
w = Label(master, text="Hello, world!")
w.pack(...
In the Python documentation and on mailing lists I see that values are sometimes "cast", and sometimes "coerced". What is the difference?
...
Would it be possible to make a python cluster, by writing a telnet server, then telnet-ing the commands and output back-and-forth? Has anyone got a better idea for a python compute cluster?
PS. Preferably for python 3.x, if anyone knows how.
...
I have a website that right now, runs by creating static html pages from a cron job that runs nightly.
I'd like to add some search and filtering features using a CGI type script, but my script will have enough of a startup time (maybe a few seconds?) that I'd like it to stay resident and serve multiple requests.
This is a side-project...
I am trying to make a simple script to automate and log synchronization via Unison. I am also using subprocess.Popen rather than the usual os.system call as it's deprecated. I've spent the past 2 days looking at docs and such trying to figure out what I'm doing wrong, but for some reason if I call unison from a terminal it works no probl...
I have a django app, and on the backend I've got a many to many field that I've set in the 'raw_id_fields' property in the ModelAdmin class. When running it locally, everything is fine, but when I test on the live site, the link to the lookup popout window doesnt work.
The django app resides at example.com/djangoapp/ and the admin is e...
In a python script, I started a bunch of threads, each of which pulls some resource at an interval using time.sleep(interval). I have another thread running, which uses the cmd module to monitor user inputs. When the user enters 'q', I call
sys.exit(0)
However, when the script is running and I enter 'q', the thread user input monitori...