python

With python: intervals at x:00 repeat

How do I sched a repeat timer for 5 min intervals. Which fire at 00 seconds, then repeat at 00. Ok, not hard real-time but as close as possible with sys lags. Trying to avoid a build up in lags and get near 00. Lang: Python, OS: WinXP x64 System has 25ms resolution. Any code would be helpful, tia ...

How do you "concatenate" two 32 bits int to get a 64 bits long in Python?

I want to generate 64 bits long int to serve as unique ID's for documents. One idea is to combine the user's ID, which is a 32 bit int, with the Unix timestamp, which is another 32 bits int, to form an unique 64 bits long integer. A scaled-down example would be: Combine two 4-bit numbers 0010 and 0101 to form the 8-bit number 00100101...

get data into sqlite from yahoo finance.

I trying to get yahoo prices into sqlite... I have the code below, but cant get the data into ipull [] then into sqlite... from urllib import urlopen import win32com.client as win32 import sqlite3 RANGE = range(3, 8) COLS = ('TICKER', 'PRICE', 'Vol') URL = 'http://quote.yahoo.com/d/quotes.csv?s=%s&f=sl1v' TICKS = ('GGP',...

Appengine datastore not updating multiple records

votergroup = db.GqlQuery("SELECT * FROM Voter WHERE lastname = :1", 'AGEE') for voter in votergroup: voter.email = '[email protected]' db.put(votergroup) The above code doesn't seem to be updating the records as it shows in the appengine documentation. I also tried using a query object to no avail. I kn...

I have a file > 1g, I want to split it into files with 100k lines each

I want to do this in python but I'm stumped. I wont be able to load the whole file into ram without things becoming unstable, so I want to read it line by line... Any advice would be appreciated. ...

sorting lines based on data in the middle of the line (in python)

I have a list of domains and I want to sort them based on tld. whats the fastest way to do this? ...

What is the Python equivalent of Ruby's "inspect"?

I just want to quickly see the properties and values of an object in Python, how do I do that in the terminal on a mac (very basic stuff, never used python)? Specifically, I want to see what message.attachments are in this Google App Engine MailHandler example (images, videos, docs, etc.). ...

Problem with sh profile in IPython on Mac

I recently heard about profiles in python and quickly discovered the sh profile. I went to invoke it to try it out and got the following error on my Mac running Snow Leopard and the system Python2.6. Anyone else see this before? I was thinking about trying to reinstall the IPython egg to see if it fixed it, but thought I'd ask if any oth...

Transform tuple to dict

How can I transform tuple like this: ( ('a', 1), ('b', 2) ) to dict: { 'a': 1, 'b': 2 } ...

[python] need checking and padding sqlite database housekeeping and manipulate code

All, Update: based on google result and answer, I added more hints, still not finished. In using sqlite3 and during study of sqlalchemy, I found it is necessary to write below code for those housekeeping purpose for managing data, however, it may be a hard part for me to doing that in sqlalchemy then I turning back to sqlite3 module. ...

Django / Python, using variablized object names

I'm confused on how to do this, I'm passing in a dictionary with different values, such as "app" which is the name of the app (so that I can better decouple code for easier modularization).. so this is just a simplified example and its not working so I'm wondering how to use the variable "app" within the string that is calling the models...

How to embed this matplotlib code into tkinter canvas!

The matplotlib code is in http://matplotlib.sourceforge.net/examples/animation/strip_chart_demo.html I want to embed this code in my tkinter GUI,what should I do ? As it say"""This example uses gtk but does not depend on it intimately. It just uses the idle handler to trigger events. You can plug this into a different GUI that support...

Help running Python multiprocessing program under SGE

I have a Python program that runs multiple threads using the multiprocessing module. The program runs fine when executed on a stand-alone machine with multiple cores, using all cores, or on a cluster when executing from the shell directly. However, when trying to run it through SGE (Sun Grid Engine), either through a job script or usin...

How to best pickle/unpickle in class hierarchies if parent and child class instances are pickled

Assume I have a class A and a class B that is derived from A. I want to pickle/unpickle an instance of class B. Both A and B define the _getstate_/_setstate_ methods (Let's assume A and B are complex, which makes the use of _getstate_ and _setstate_ necessary). How should B call the _getstate_/_setstate_ methods of A? My current, but per...

What is the Ruby equivalent of this string formatting?

From Python... s = "hello, %s. Where is %s?" % ("John","Mary") How do you do that in Ruby? ...

Integrating messenger to an existing website

For an existing website and the users in it,how to integrate a chat application like yahoo or gmail or any other with minimum code changes. ...

Add image dinamically to wx.StaticBitmap?

It is possible to add dinamically images to wx.StaticBitmap? Now I can only add one image and only change existing image. I want to display next image after new line or sth else. My actual code: self.images = wx.StaticBitmap(self, id=-1, pos=wx.DefaultPosition, size=(-1,100), sty...

Histogram Equalization

I am a beginner in Python. I want to make a small project on histogram equalisation. Basically I want to include changing contrast, color and crop option etc in my project. I am blank right now. Please suggest something. I am very keen to make this project but how to start? ...

Get a list of the absolute paths of all the images in a page using BeautifulSoup

Could someone show me how to get a list of aboslute paths for all the images in a webpage using BeautifulSoup? It's simple to get all the images. I'm doing this: page_images = [image["src"] for image in soup.findAll("img")] ...but I'm having difficulties getting the absolute paths. Any help? Thank you. ...

How to match all .sass request to a particular controller in pylons?

I'm using pylons, and want to use clever css. I created a controller SassController to handle .sass requests, but in the config/routing.py, I don't know how to write the mapping. What I want is: client request: http://localhost:5000/stylesheets/questions/index.sass all such requests will be handled by SassController#index I tried: ...