I want to execute an external program in each thread of a multi-threaded python program.
Let's say max running time is set to 1 second. If started process completes within 1 second, main program capture its output for further processing. If it doesn't finishes in 1 second, main program just terminate it and start another new process.
How to implement this?
I got a headache looking for this:
How do you use s/// in an expression as opposed to an assignment. To clarify what I mean, I'm looking for a perl equivalent of python's re.sub(...) when used in the following context:
newstring = re.sub('ab', 'cd', oldstring)
The only way I know how to do this in perl so far is:
$oldstring =~ s/ab/cd/;
$newstring = $oldstring;
Note the extra assignment.
Hi,
I'm using Google Book Search API to add missings bits and pieces to my database.
Problem is that The API gives me back a list of book editions, and not reference to the original book itself.
The data I'm trying to get is this:
Original title: The Hobbit
Original year of publication: 1937
Can anyone help?
Just in case anyone asks: I'm developing this in Python.
Hi, I have a guitar and I need my pc to be able to tell what note is being played, recognizing the tone. Is it possible to do it in python, also is it possible with pygame? Being able of doing it in pygame would be very helpful.
I tried to install pygtk on mac. I downloaded the pygtk file, opened up terminal and set it to my working directory, then ran the command "python setup.py install". There was an import error because there was no module dsextras. Does anyone know how to install pygtk on a mac or get dsextras.
I believe it's because I installed python using SciPy, so apparently it's not in the registry where the psycopg2 installer is looking. Anyway to fix this without installing python26 over the existing install? I'm not sure if that will corrupt it.
Hi all.
What are the most stable and useful Cryptography libraries, that they are:
written with/for python, c++, c#, .net
opensource, GNU, or other free license
how would i search through a list with ~5 mil 128bit (or 256, depending on how you look at it) strings quickly and find the duplicates (in python)? i can turn the strings into numbers, but i don't think that's going to help much. since i haven't learned much information theory, is there anything about this in information theory?
and since these are hashes already, there's no point in hashing them again
I want to make my component faster, I am using Javascript and JQuery to build that.
I am using JSON object to communicate with component and back-end is python.
Is there any suggestion to make component faster?
I need to do a fairly extensive project involving web scraping and am considering using Hpricot or Beautiful Soup (i.e. Ruby or Python). Has anyone come across a tutorial that they thought was particularly good on this subject that would help me start the project off on the right foot?
I want to learn the following:
apache - i don't know for sure what is for
linux - server edition, the os of the server
python - for server side scripting
java - sockets, jsp, other
Am I missing anything? Are there better alternatives ? How should I start? What is apache for ?
I'm running PyLint from inside Wing IDE on Windows. I have a sub-directory (package) in my project and inside the package I import a module from the top level, ie.
__init__.py
myapp.py
one.py
subdir\
__init__.py
two.py
Inside two.py I have import one and this works fine at runtime, because the top-level directory (from which myapp.py is run) is in the Python path. However, when I run PyLint on two.py it gives me an error:
F0401: Unable to import 'one'
How do I fix this?
My doc strings have references to other python classes that I've defined. Every time Sphinx encounters one of these classes, I want it to insert a link to the documentation for that other class. Is this possible in Sphinx?
Specifically, I have a doc string like:
'''This class contains a bunch of Foo objects'''
I could write:
'''This class contains a bunch of :class:`~foo.Foo` objects'''
but I would prefer that Sphinx finds all text matching Foo and makes it seem as though I had typed
:class:~foo.Foo
I'm researching how to best extend a C++ application with scripting capability, and I am looking at either Python or JavaScript. User-defined scripts will need the ability to access the application's data model.
Have any of you had experiences with embedding these scripting engines? What are some potential pitfalls?
The Selenium setup.py can be found at http://code.google.com/p/selenium/source/browse/trunk/setup.py.
When running "python setup.py sdist" the "firefox/test/py" directory
is ignored for some reason though it's
mentioned in the "package_dir" and in "packages".
Any ideas why it's ignored?
Hi
A client of ours is asking us to implement a module in C in Apache webserver for performance reasons. This module should handle RESTful uri's, access a database and return results in json format. Many people here have recommended python mod_wsgi instead - but for simplicity of programming reasons. Can anyone tell me if there is a significant difference in performance between the mod_wsgi python solution vs. the Apache + C.module. Any anecdotes? Pointers to some study posted online?
What am I doing wrong/what can I do?
import sys
import string
def remove(file):
punctuation = string.punctuation
for ch in file:
if len(ch) > 1:
print('error - ch is larger than 1 --| {0} |--'.format(ch))
if ch in punctuation:
ch = ' '
return ch
else:
return ch
ref = (open("ref.txt","r"))
test_file = (open("test.txt", "r"))
dictionary = ref.read().split()
file = test_file.read().lower()
file = remove(file)
print(file)
This is in Python 3.1.2
What regular expression can I use (if any) to validate that a given string is a legal ssh rsa public key?
I only need to validate the actual key - I don't care about the key type the precedes it or the username comment after it.
Ideally, someone will also provide the python code to run the regex validation.
Thanks.
I wrote a function in Python:
def instantiate(c):
if inspect.isclass(c): return c()
elif isinstance(c, object): return c
else: raise Exception, '%s is not an object or class.' % c
Now I want to do the opposite: get the class from an already instantiated object so that I can re-instantiate it with different parameters. How can I do that?
I am planning to use py2exe to make an application developped with Python 2.6.
It seems that my app need the VC redistribuables : http://www.py2exe.org/index.cgi/Tutorial#Step5
I've read this tutorial and the redistribuables license agreement and I am not sure if I can freely redistribute these files with my program. (I don't have VS2008 license)
Can I bundle the redistribs into an installer and make the installation transparent for the user or do they have to download the files by their own from Microsoft website?
Thanks in advance
Hello,
Is there a way i can programmatically determine the status of a download in Chrome or Mozilla Firefox. I would like to know if the download was aborted or completed successfully.
For writing the code id be using either perl,php or python.
Please help.
Thank You.
I have done a little django development but it has all been in a text editor. I was curious what more advanced development tools others are using in their django development. I am used to using Visual Studio for development and really like the intellisense, code completion, and file organization it provides and would like to find something (or a combination of tools) that would provide some of this in the django/python environment.