python

Embed python interpreter in a python application

Hi, i'm looking for a way to ship the python interpreter with my application (also written in python), so that it doesn't need to have python installed on the machine. I searched google and found a bunch of results about how to embed the python interpreter in applications written in various languages, but nothing for applications writte...

How to implement Comet server side with Python?

I once tried to implement Comet in PHP. Soon, I found that PHP is not suitable for Comet, since each HTTP request will occupy one process/thread. As a result, it doesn't scale well. I just installed mod_python in my XAMPP. I thought it would be easy to implement Comet with Python asynchronous programming. But still cannot get a clue ho...

What are good Python and/or Django deployment solutions?

For now I use some mix between virtual_env, pip and Fabric. This allows to: install required libs; generate dynamic content; isolate installation; push everything through ssh. It works well, I just want to know if there are other tools around. The only problem I could think of is that it's a lot of to set up every time. It doesn't s...

Weird characters in exported csv files when converting

Hey guys, I came across a problem I cannot solve on my own concerning the downloadable csv formatted trends data files from Google Insights for Search. I'm to lazy to reformat the files I4S gives me manually what means: Extracting the section with the actual trends data and reformatting the columns so that I can use it with a modellin...

How do you use pip, virtual_env and Fabric to handle deployement?

What are your settings, your tricks, and above all, your work flow? These tools are great but they are still no best practices attached to their usage, so I don't know what is the most efficient way to use them. Do you use pip bundles or always download? Do you set up Apache/Cherokee/MySQL by hand or do you have a script for than. D...

PySVN: is property status "none" equivalent to unchanged?

I know the practical difference between a PySVN property status of "normal" (has properties, not changed locally) and "none" (has no properties). My question is this: is it ever possible for there to be local modifications to an items properites, and have PySVN report the property status as "none"? I would say no, but maybe there's some...

Django database - how to add this column in raw SQL.

Suppose I have my models set up already. class books(models.Model): title = models.CharField... ISBN = models.Integer... What if I want to add this column to my table? user = models.ForeignKey(User, unique=True) How would I write the raw SQL in my database so that this column works? ...

How to discover table properties from SQLAlchemy mapped object

Hi, My point is i have a class mapped with a table, in my case in a declarative way, and i want to "discover" table properties, columns, names, relations, from this class : engine = create_engine('sqlite:///' + databasePath, echo=True) # setting up root class for declarative declaration Base = declarative_base(bind=engine) class Shi...

Python: puzzling behaviour inside httplib

I have added one line ( import pdb; pdb.set_trace() ) to httplib's HTTPConnection.putheader, so I can see what's going on inside. Python26\Lib\httplib.py, line 489: def putheader(self, header, value): """Send a request header line to the server. For example: h.putheader('Accept', 'text/html') """ import pdb; pdb.set_t...

Is there an API for Aardvark?

Is there an API for Aardvark (http://vark.com)? How can I programmatically ask questions and get answers? ...

[Gdata] GetAuthSubToken returns None

Hey guys, I am a little lost on how to get the auth token. Here is the code I am using on the return from authorizing my app: client = gdata.service.GDataService() gdata.alt.appengine.run_on_appengine(client) sessionToken = gdata.auth.extract_auth_sub_token_from_url(self.request.uri) client.UpgradeToSessionToken(sessionToken) logging.i...

matplotlib: how to refresh figure.canvas

Hello, I can't understand how to refresh FigureCanvasWxAgg instance. Here is the example: import wx import matplotlib from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas from matplotlib.figure import Figure class MainFrame(wx.Frame): def __init__(self): wx.Frame.__init__(self, None, wx.NewId(...

How to find out the exact RSS XML path of a website?

How do I get the exact feed.xml/rss.xml/atom.xml path of a website? For example, I supplied "http://www.example.com/news/today/this_is_a_news", but the rss is pointing to "http://www.example.com/rss/feed.xml", most modern browsers have this features already and I'm curious how did they get them. Can you cite an example code in ruby, py...

Accessing Class Variables from a List in a nice way in Python

Suppose I have a list X = [a, b, c] where a, b, c are instances of the same class C. Now, all these instances a,b,c, have a variable called v, a.v, b.v, c.v ... I simply want a list Y = [a.v, b.v, c.v] Is there a nice command to do this? The best way I can think of is: Y = [] for i in X Y.append(i.v) But it doesn't seem ...

Tree libraries in python

Are there any python libraries for data trees? I mean a tree as a general data structure, not just an xml tree. (Like in this question, but in python.) ...

Python, SWIG and other strange things

hey, I have a firmware for an USB module I can already control by visual C. Now I want to port this to python. for this I need the octopus library which is written in c. I found a file called octopus_wrap which was created by SWIG! then I found a makefile which says: python2.5: swig -python -outdir ./ ../octopus.i gcc ...

how to search for file's has a known file extension like .py ??

how to search for file's has a known file extension like .py ?? fext = raw_input("Put file extension to search: ") dir = raw_input("Dir to search in: ") ##Search for the file and get the right one's ...

Python: Removing tuples from a list of lists

I have a list of lists containing tuples: [[(1L,)], [(2L,)], [(3L,)], [(4L,)], [(5L,)] how do i edit the list so the list looks like: l = [[1][2][3][4][5]] ...

How to delete an element from a list while iterating it in Python?

Suppose I have a list of numbers: L = [1, 2, 3, 4, 5] How do I delete an element, let's say 3, from the list while I iterate it? I tried the following code but it didn't do it: for el in L: if el == 3: del el Any ideas? Thanks, Boda Cydo. ...

Calculating Hebrew date in Python

I'd like to calculate Hebrew dates (primarily the current Hebrew date) in Python. Which library is mature, easy to use, and documented? I note these. There may be others. Python Date Utilities Library as discussed here Calendrical libhdate Python bindings This informal code listing. ...