python

A question on python sorting efficiency

Alright so I am making a commandline based implementation of a website search feature. The website has a list of all the links I need in alphabetical order. Usage would be something like ./find.py LinkThatStartsWithB So it would navigate to the webpage associated with the letter B. My questions is what is the most efficient/smartes...

Coding collaboratively for the web

In the past I've done the coding-part of my web-projects mostly by myself. Now, as we are a team working on some project, be it phython or php or ..., is there some simple versioning system to use? My hoster doesn't seem to support any kind of this sort. On the other hand, I feel it is too early to start renting a whole server in this p...

SQLite parameter substitution and quotes

I have this line that works OK: c.execute('select cleanseq from cleanseqs WHERE newID="%s"'%name) But I want to use SQLite parameter substitution instead instead of string substitution (because I see here that this is safer). This is my (failed) try: t = (name,) c.execute('select cleanseq from cleanseqs WHERE newID="?"',t) But thi...

Gantt Chart online

I need to insert a horizontal bar chart in a web page. The thing I have to do is very similar to a Gantt Chart. I'd like to use a javascript library for the purpose. I tried jsgantt, but actually it is not very beautiful. I could evaluate also a server generation of the graph. In case my server side language is Python. It will be part...

What is the runtime complexity of python list functions?

I was writing a python function that looked something like this def foo(some_list): for i in range(0, len(some_list)): bar(some_list[i], i) so that it was called with x = [0, 1, 2, 3, ... ] foo(x) I had assumed that index access of lists was O(1), but was surprised to find that for large lists this was significantly slowe...

Can I trace all the functions/methods executing in a python script?

Is there a way to programmatically trace the execution of all python functions/methods? I would like to see what arguments each of them was called with. I really mean all, I'm not interested in a trace decorator. In Ruby, I could alias the method I wanted and add the extra behaviour there. ...

What is the easiest way to see if a process with a given pid exists in Python?

In a POSIX system, I want to see if a given process (PID 4356, for example) is running. It would be even better if I could get metadata about that process. ...

How do I look inside a Python object?

I'm starting to code in various projects using Python (including Django web development and Panda3D game development). To help me understand whats going on, I would like to basically 'look' inside the Python objects to see how they tick - like their methods and properties. So say I have a Python object, what could would I need to print o...

A Python buffer that you can truncate from the left?

Right now, I am buffering bytes using strings, StringIO, or cStringIO. But, I often need to remove bytes from the left side of the buffer. A naive approach would rebuild the entire buffer. Is there an optimal way to do this, if left-truncating is a very common operation? Python's garbage collector should actually GC the truncated bytes. ...

How to do a meaningful code-coverage analysis of my unit-tests?

I manage the testing for a very large financial pricing system. Recently our HQ have insisted that we verify that every single part of our project has a meaningful test in place. At the very least they want a system which guarantees that when we change something we can spot unintentional changes to other sub-systems. Preferably they want...

How to find out the number of CPUs in python

I want to know the number of CPUs on the local machine in Python. The result should be user/real as output by time(1) when called with an optimally scaling userspace-only program. I'd be interested in any better ways to solve that problem. ...

Capitalizing non-ASCII words in Python

How to capitalize words containing non-ASCII characters in Python? Is there a way to tune string's capitalize() method to do that? ...

Simple python plugin system

Hi all! I'm writing a parser for an internal xml-based metadata format in python. I need to provide different classes for handling different tags. There will be a need for a rather big collection of handlers, so I've envisioned it as a simple plugin system. What I want to do is simply load every class in a package, and register it with m...

What would the jvm have to sacrifice in order to implement tail call optimisation?

People say that the clojure implementation is excellent apart from the limitation of having no tail call optimisation - a limitation of the jvm not the clojure implementation. http://lambda-the-ultimate.org/node/2547 It has been said that to implement TCO into Python would sacrifice stack-trace dumps, and debugging regularity. h...

wxProgressDialog like behaviour for a wxDialog

I want to create modal dialog but which shouldn't behave in a modal way i.e. control flow should continue if i do dlg = wx.Dialog(parent) dlg.ShowModal() print "xxx" dlg.Destroy() "xxx" will not get printed, but in case of progress dialog dlg = wx.ProgressDialog.__init__(self,title, title, parent=parent, style=wx.PD_APP_MODAL)...

OLE Compound Documents in Python

Hi everyone, how would you parse a Microsoft OLE compound document using Python? Edit: Sorry, I forgot to say that I need write support too.. In short, I have an OLE compound file that I have to read, modify a bit and write back to disk (it's a file made with a CAD application) ...

How to retrieve the selected text from the active window

I am trying to create a simple open source utility for windows using Python that can perform user-defined actions on the selected text of the currently active window. The utility should be activated using a pre-defined keyboard shortcut. Usage is partially outlined in the following example: The user selects some text using the mouse o...

How do you make this code more pythonic?

Could you guys please tell me how I can make the following code more pythonic? The code is correct. Full disclosure - it's problem 1b in Handout #4 of this machine learning course. I'm supposed to use newton's algorithm on the two data sets for fitting a logistic hypothesis. But they use matlab & I'm using scipy Eg one question i have...

Using Perl, Python, or Ruby, how to write a program to "click" on the screen at scheduled time?

Using Perl, Python, or Ruby, can I write a program, probably calling Win32 API, to "click" on the screen at scheduled time, like every 1 hour? Details: This is for experimentation -- and can the clicking be effective on Flash content as well as any element on screen? It can be nice if the program can record where on screen the click...

Stomp over SSL USING PYTHON.............

iam trying to find a good python client to test stomp over ssl im using a Fuse Message Broker...........and intend to implement atleast client side authentication later......... can anyone help me get started ...