I want to use multithreading to make my script faster...
I'm still new to this. The Python doc assumes you already understand threading and what-not.
So...
I have code that looks like this
from itertools import izip
from multiprocessing import Pool
p = Pool()
for i, j in izip(hugeseta, hugesetb):
p.apply_async(number_crunching, ...
I'm connection to mssql server through pyodbc, via FreeTDS odbc driver, on linux ubuntu 10.04.
Sqlalchemy 0.5 uses DATETIME for sqlalchemy.Date() fields.
Now Sqlalchemy 0.6 uses DATE, but sql server 2000 doesn't have a DATE type. How can I make DATETIME be the default for sqlalchemy.Date() on sqlalchemy 0.6 mssql+pyodbc dialect?
I'd l...
I am looking for a practical visual programming environment based on Python. My primary application is algorithm development for processing remote-sensing imagery. I was initially inspired by LabVIEW from National Instruments, but that is more geared towards laboratory measurements and simulations. I write a lot of prototype code in P...
In Python, I have code that catches an exception, like this:
try:
<do stuff>
except:
exc_info = sys.exc_info()
The problem I'm running into is that the traceback object (exc_info[2]) is non-deterministically missing local variables in the traceback objects. I know this for a fact because I run the exact same code and sometimes...
I have a table, Foo. I run a query on Foo to get the ids from a subset of Foo. I then want to run a more complicated set of queries, but only on those IDs. Is there an efficient way to do this? The best I can think of is creating a query such as:
SELECT ... --complicated stuff
WHERE ... --more stuff
AND id IN (1, 2, 3, 9, 413, 4324, ....
I have very little idea what I'm doing here, I've never done anything like this before, but a friend and I are writing competing chess programs and they need to be able to communicate to each other.
He'll be writing mainly in C, the bulk of mine will be in Python, and I can see a few options:
Alternately write to a temp file, or succe...
Hello,
I am using this python script do display my webcam :
from opencv.cv import *
from opencv.highgui import *
import sys
cvNamedWindow("w1", CV_WINDOW_AUTOSIZE)
camera_index = 0
capture = cvCreateCameraCapture(camera_index)
def repeat():
global capture #declare as globals since we are assigning to them now
global came...
hi all,
I'm developing a system where a queue will be filled with millions of items
I need a process that reads items from the queue constantly and then sends those items out to registered clients.
I'm thinking about using twisted for this, having the queue reader be a twisted server listening on a tcp port then clients can connect o...
I want to run many select queries at once by putting them between BEGIN; END;. I tried the following:
cur = connection.cursor()
cur.execute("""
BEGIN;
SELECT ...;
END;""")
res = cur.fetchall()
However, I get the error:
psycopg2.ProgrammingError: no results to fetch
How can I actually get data this way?
Likewise, if I just have ma...
To implement a status bar like below:
[========== ] 45%
[================ ] 60%
[==========================] 100%
I want to this to be printed out to stdout, and keep refreshing it, not print to another line. How to do this? thanks.
...
I'm using Matplotlib to dynamically generate .png charts from a database. The user may set as the x-axis any given range of datetimes, and I need to account for all of it. While Matplotlib has the dates.AutoDateLocator(), I want the datetime format printed on the chart to be context-specific - e.g. if the user is charting from 3 p.m. to ...
I need to come up with a file format for new application I am writing.
This file will need to hold a bunch other text files which are mostly text but can be other formats as well.
Naturally, a compressed tar file seems to fit the bill.
The problem is that I want to be able to retrieve some data from the file very quickly and getting just...
Hi
Disclaimer: completely new to Python from a PHP background
Ok I'm using Python on Google App Engine with Google's webapp framework.
I have a function which I import as it contains things which need to be processed on each page.
def some_function(self):
if data['user'].new_user and not self.request.path == '/main/new':
...
Hey,
I'm trying to update a user status from a django python app.
The user went thru facebook connect and registers to the app.
I got sessionkey and fbuid.
fb = Facebook(FACEBOOK_API_KEY, FACEBOOK_SECRET_KEY)
if fbsessionkey:
fb.session_key = fbsessionkey
fb.uid = fbuid
fb.auth.createToken()
fb.au...
I have this small script that sorts the content of a text file
# The built-in function `open` opens a file and returns a file object.
# Read mode opens a file for reading only.
try:
f = open("tracks.txt", "r")
try:
# Read the entire contents of a file at once.
# string = f.read()
# OR read one line at ...
I'm building an ASP.NET MVC (C#) site where I want to implement STV (Single Transferable Vote) voting. I've used OpenSTV for voting scenarios before, with great success, but I've never used it programmatically.
The OpenSTV Google Code project offers a Python script that allows usage of OpenSTV from other applications:
import sys
sys.pa...
hey guys does beautifulSoup strips css and javascript content? after using
content3 = ''.join(BeautifulSoup(content).findAll(text=True))
i still have them lingering around.
...
Hi folks...I have a dictionary with embedded objects, which looks something like this:
notes = {
2009: [<Note: Test note>, <Note: Another test note>],
2010: [<Note: Third test note>, <Note: Fourth test note>],
}
I'm trying to access each of the note objects inside a django template, and having a helluva time navigating to them...
I am using django-mssql and SQL Server 2008, but I found that it always errors when I do some
commands,for example:
python manage.py syncdb
the error is below:
raise OperationalError(e, "Error opening connection: " + connection_string) sqlserver_ado.dbapi.OperationalError: (com_error(-2147352567, '\xb7\xa2\xc9\xfa\ xd2\xe2\xcd\xe2\xa...
Tornado enables win32 support by faking Python's fcntl function using SetHandleInformation, which is available via ctypes on Windows. After some other small fixes, this actually works using IronPython on Windows as well (sadly, IronPython is five times slower).
I'd like to get Tornado working on any CLI platform, such using Mono on O...