python

Getting method parameter names in python

Given the python function: def aMethod(arg1, arg2): pass How can I extract the number and names of the arguments. Ie. given that I have a reference to func, I want the func.[something] to return ("arg1", "arg2") The usage scenario for this is that I have a decorator, and I wish to use the method arguments in the same order that t...

What is a good open source pastebin in Python or Perl?

Hello, I'm looking for an open-source pastebin web-application written in either Python or Perl. I need it in order to implement a web-based specialized editor for my own needs, and I want to borrow code / ideas from the pastebin since I don't have much experience in web programming. Can you point to one (or a few) ? Thanks in advanc...

How do you share data between a parent and forked child process in Python?

I'm pretty sure one would do this using the os.plock(op) function, but I have no idea how. Also, if there's a better way, I'd be grateful to find out. Code snippets are very welcome. Thanks! ...

how can i use sharepoint (via soap?) from python ?

I want to use Sharepoint with python (C-Python) Has anyone tried this before ? ...

How Python web frameworks, WSGI and CGI fit together

Hello, I have a Bluehost account where I can run Python scripts as CGI. I guess it's the simplest CGI because to run I have to define the following in .htaccess: Options +ExecCGI AddType text/html py AddHandler cgi-script .py Now, whenever I look up web programming with Python, I hear a lot about WSGI and how most frameworks use it. ...

How do I use Tkinter with Python on Windows Vista?

I installed Python 2.6 for one user on Windows Vista. Python works okay, but when I try: import Tkinter, it says the side-by-side configuration has errors. I've tried tinkering with the Visual Studio runtime, with no good results. Any ideas on how to resolve this? ...

django,fastcgi: how to manage a long running process?

I have inherited a django+fastcgi application which needs to be modified to perform a lengthy computation (up to half an hour or more). What I want to do is run the computation in the background and return a "your job has been started" -type response. While the process is running, further hits to the url should return "your job is still ...

I’m stunned: weird problem with python and sockets + threads

I have a python script that is a http-server: http://paste2.org/p/89701, when benchmarking it against ApacheBench (ab) with a concurrency level (-c switch) that is lower then or equal to the value i specified in the socket.listen()-call in the sourcecode everything works fine, but as soon as put the concurrency level in apache bench abov...

Ensuring a single instance of an application in Linux

I'm working on a GUI application in WxPython, and I am not sure how I can ensure that only one copy of my application is running at any given time on the machine. Due to the nature of the application, running more than once doesn't make any sense, and will fail quickly. Under Win32, I can simply make a named mutex and check that at start...

Including PYDs/DLLs in py2exe builds

One of the modules for my app uses functions from a .pyd file. There's an option to exclude dlls (exclude_dlls) but is there one for including them? The build process doesn't seem to be copying the .pyd in my module despite copying the rest of the files (.py). I also need to include a .dll. How do I get py2exe to include both .pyd and ....

Best video manipulation library for python?

I'd like to include some simple video editing functionality for the python application I'm writing and googling comes up with: pymedia pyglet (using the media module) gst-python Requirements: Small footprint. I'm already using wxpython (just because), which bloats up the final .exe pretty easily so preferably whatever I use to imp...

load dll from python

Hello. I'm building a python application from some source code I've found Here I've managed to compile and fix some problems by searching the web, but I'm stuck at this point: When running the application this message appears. This python app, usues swig to link to c/c++ code. I have VC++2005 express edition which I used to compi...

Free Python hosting

Is there a free working python host on which I can live test a django app? Google app engine is not an option. ...

What is the best way on python 2.3 for windows to execute a program like ghostscript with multiple arguments and spaces in paths?

Surely there is some kind of abstraction that allows for this? This is essentially the command cmd = self._ghostscriptPath + 'gswin32c -q -dNOPAUSE -dBATCH -sDEVICE=tiffg4 -r196X204 -sPAPERSIZE=a4 -sOutputFile="' + tifDest + " " + pdfSource + '"' os.popen(cmd) this way looks really dirty to me, there must be some ...

How can I write a method within a Django model to retrieve related objects?

I have two models. We'll call them object A and object B. Their design looks something like this: class Foo(models.Model): name = models.CharField() class Bar(models.Model): title = models.CharField() Foo= models.ForeignKey('myapp.Foo') Now, suppose I want to make a method within Foo that returns all Bar objects that r...

Is it possible to implement Python code-completion in TextMate?

PySmell seems like a good starting point. I think it should be possible, PySmell's idehelper.py does a majority of the complex stuff, it should just be a case of giving it the current line, offering up the completions (the bit I am not sure about) and then replacing the line with the selected one. >>> import idehelper >>> # The path is...

Putting Copyright Symbol into a Python File

I need to include a copyright statement at the top of every Python source file I produce: # Copyright: © 2008 etc. However, when I then run such a file I get this message: SyntaxError: Non-ASCII character '\xa9' in file MyFile.py on line 3, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details. Apparen...

Removing a sequence of characters from a large binary file using python

I would like to trim long sequences of the same value from a binary file in python. A simple way of doing it is simply reading in the file and using re.sub to replace the unwanted sequence. This will of course not work on large binary files. Can it be done in something like numpy? ...

Is it possible to set a timeout on a socket in Twisted?

I realize I'm probably just dumb and missing something big and important, but I can't figure out how to specify a timeout in twisted using reactor.listenUDP. My goal is to be able to specify a timeout, and after said amount of time, if DatagramProtocol.datagramReceived has not been executed, have it execute a callback or something that I...

Best approach with dynamic classes using Python globals()

Hi! I'm working on a web application that will return a variable set of modules depending on user input. Each module is a Python class with a constructor that accepts a single parameter and has an '.html' property that contains the output. Pulling the class dynamically from the global namespace works: result = globals()[classname](para...