python

Snow Leopard and Enthought Tool Suite problems: cannot install Enable

I'm an OS X novice who has been pulling hair out trying to install ETS components on Snow Leopard. The initial problem centred round the message. /Developer/SDKs/MacOSX10.4u.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory I came across a fix which involves (a) loading the mac 10.4 SDK from the Snow Leo...

Embedded WSGI backend for Python desktop app using webkit

Disclaimer: I'm not very familiar with any of the things mentioned in the question title. Would it be possible to use a browser control (like Webkit) as a frontend for a WSGI app (using a framework like Flask) without starting a local WSGI server? Basically the requests and responses are managed by a middle layer between the HTML UI an...

Loading mako templates from files

I'm new to python and currently trying to use mako templating. I want to be able to take an html file and add a template to it from another html file. Let's say I got this index.html file: <html> <head> <title>Hello</title> </head> <body> <p>Hello, ${name}!</p> </body> </html> and this name.html file: world (yes, it just ...

How can I access Oracle from Python?

How can I access Oracle from Python? I have downloaded a cx_Oracle mis but Python can't import the library. I get the following error import cx_Oracle Traceback (most recent call last): File "", line 1, in import cx_Oracle ImportError: DLL load failed: The specified module could not be found. I will be grateful for any help ...

Call a Python method by name

If I have an object and a method name in a string, how can I call the method? class Foo: def bar1(self): print 1 def bar2(self): print 2 def callMethod(o, name): ??? f = Foo() callMethod(f, "bar1") ...

How to: create .doc files using templates with django/python

Hello, I am writing a django application and there is something I don't know how to do. Say you have a database with users and several .doc files you might want to send to those users (postal letters, not electronicaly). I am wondering if there is a way to automatically create those letters from templates using my user database to fill ...

Quickly remove first n lines from many text files

I need to create an output text file by deleting the first two lines of the input file. At the moment I'm using sed "1,2d" input.txt > output.txt I need to do this for thousands of files, so am using python: import os for filename in somelist: os.system('sed "1,2d" %s-in.txt > %s-out.txt'%(filename,filename)) but this is quite slo...

Google App Engine, Python and IPython

I want to use IPython under GAE to debug scripts locally: import ipdb; ipdb.set_trace() but GAE restricts loading some modules from sys.path. Can I bypass this somehow? ...

Speech recognition in Python

Hi every one. I found the speech module and i can get my computer to say the stuff i write. But the problem is when i try out the example code from here: http://pypi.python.org/pypi/speech/0.5.1 It gives me an error and can't do it. This is the error i get: Traceback (most recent call last): File "<pyshell#1>", line 1, in <module> resp...

Retrieving stdout from subprocess in Windows.

I can call FFmpeg with subprocess.Popen and retrieve the data I need, as it occurs (to get progress), but only in console. I've looked around and seen that you can't get the data "live" when running with pythonw. Yet, waiting until the process finishes to retrieve the data is moot, since I'm trying to wrap a PyQT GUI around FFmpeg so I c...

html to text conversion using python language

I'd like to extract the text from an HTML file using Python. I want essentially the same output I would get if I copied the text from a browser and pasted it into notepad. I'd like something more robust than using regular expressions that may fail on poorly formed HTML. I've seen many people recommend Beautiful Soup, but I've had a few ...

Django mod-python error

Can someone please tell what this strange error is Mod_python error: "PythonHandler django.core.handlers.modpython" Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line 287, in HandlerDispatch log=debug) File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line 464, in imp...

Removing broken tags and poorly formatted html from some text

i have a huge database of scraped forum posts that i am inserting into a website. however alot of people try to use html in their forum posts and often times do it wrong. because of this, there are always stray <strike> <b> </strike> </div> </b> tags in the posts which will end up messing up the webpage format when i add say 15 forum po...

Changing the directory where .pyc files are created

Is there a way to change the directory where .pyc file are created by python interpreter ? I saw two PEPs about that subject (0304 and 3147), but none seems to be implemented in the default interpreter (I'm working with python3). Did I miss something ? Thanks ! ...

Which framework is the most friendly for shared hosting environment?

I am currently comparing available web frameworks to be used for my next projects. The only criterion I need are speed and portability, i.e shared hosting friendly. I have tried Ruby on Rails, but its speed/performance is not good enough for me. I am interested in Django, but I think it is not that friendly on shared hosting - correct m...

Python 2 or Python 3 as the student's first language

Which is more suited as the platform for a first course in computing: Python 2 or Python 3? Reason for asking your opinion: Python 2 is used in the vast majority of installations worlwide, but Python 3 is the coming thing. ...

Using the facebook connect JavaScriptSDK redirecting to port :8000

I'm running a Django server on localhost:8000/ and have the facebook callback URL set to exactly that "http://localhost:8000/" however, when I log in, it redirects to "http://localhost/". Is there a way around this? What am I doing wrong? ...

Sandboxing web services with Python

I'm building an integration test for a web application that has multiple interdependent services. All of them depend on a shared resource in order to run correctly. I'd like to make sure that the data in the system is sane when its live so I'm leveraging a live service. I'm using Python to build it and this is my idea on how to sandbox t...

Python Server Help

I have written a small HTTP server and everything is working fine locally, but I am not able to connect to the server from any other computer, including other computers on the network. I'm not sure if it is a server problem, or if I just need to make some adjustments to Windows. I turned the firewall off, so that can't be the probelm. I...

Rotating images using PHP and jQuery the fast way

I wrote a python script that rotates an image 90 degrees. I am including the python code in case you want to see it; #! /usr/bin/python # This Python file uses the following encoding: utf-8 #argv[1] needs to be send formatted meaning spaces and paranthesis ARE problems __author__="john" __date__ ="$Aug 17, 2010 1:48:36 PM$" server_d...