python

Porting matlab functions to scilab. How to use symbolic?

I'm porting some matlab functions to scilab. The cool thing is that there is a conversion toolbox that make things very easy. The problem is I did not find the counter part to the syms function, and the symbolic toolbox in general. (I'd like a port of the Control System Toolbox too, i'm still searching for some functions I'd may need). ...

Upgrading Google Application Engine program to use unicode

I have a simple Google App Engine app, that I wrote using ordinary strings. I realize I want to make it handle unicode. Are there any gotchas with this? I'm thinking of all the strings that I currently already have in the live database. (From real users who I don't want to upset.) ...

What are "first class" objects?

When are objects or something else said to be "first class" in a given programming language, and why? In what do they differ from languages where they are not? EDIT. When one says "everything is an object" (like in Python), does he indeed mean that "everything is first-class"? ...

Which library should I use to write an XLS from Linux / Python?

I'd love a good native Python library to write XLS, but it doesn't seem to exist. Happily, Jython does. So I'm trying to decide between jexcelapi and Apache HSSF: http://www.andykhan.com/jexcelapi/tutorial.html#writing http://poi.apache.org/hssf/quick-guide.html (I can't use COM automation because I'm not on Windows, and even if I was...

Running Django with FastCGI or with mod_python

which would you recommend? which is faster, reliable? apache mod_python or nginx/lighttpd FastCGI? ...

How do I get the name of a function or method from within a Python function or method?

I feel like I should know this, but I haven't been able to figure it out... I want to get the name of a method--which happens to be an integration test--from inside it so it can print out some diagnostic text. I can, of course, just hard-code the method's name in the string, but I'd like to make the test a little more DRY if possible. ...

How do I draw text at an angle using python's PIL?

Using Python I want to be able to draw text at different angles using PIL. For example, imagine you were drawing the number around the face of a clock. The number 3 would appear as expected whereas 12 would we drawn rotated counter-clockwise 90 degrees. Therefore, I need to be able to draw many different strings at many different angl...

Upload a file in Django and then send it somewhere else through REST?

I am building a simple Django app that will use scribd to display documents. I would like to have a page where the administrator can upload documents to scribd through the website, since I need to know a few things about it before it gets to scribd. What is the best/easiest way to do this, display an upload page and then take the file th...

When is not a good time to use python generators?

This is rather the inverse of What can you use Python generator functions for?: python generators, generator expressions, and the itertools module are some of my favorite features of python these days. They're especially useful when setting up chains of operations to perform on a big pile of data--I often use them when processing DSV fil...

HTTP compliance testing

What would you use to perform a compliance testing of an HTTP proxy? I've seen two projects so far: Web Polygraph (the feedback I got from a coworker is mostly negative) Funkload ...

Can I call and set the Python gettext module in a library and a module using it at the same time ?

Im a coding a library inluding textual feedback that I need to translate. I put the following lines in a _config.py module that I import everywhere in my app : import gettext, os, sys pathname = os.path.dirname(sys.argv[0]) localdir = os.path.abspath(pathname) + "/locale" gettext.install("messages", localdir) I have the *.mo files in...

How can I draw a bezier curve using Python's PIL?

I'm using Python's Imaging Library and I would like to draw some bezier curves. I guess I could calculate pixel by pixel but I'm hoping there is something simpler. ...

How do I add tab completion to the Python shell?

When starting a django application using python manage.py shell, I get an InteractiveConsole shell - I can use tab completion, etc. Python 2.5.1 (r251:54863, Apr 15 2008, 22:57:26) [GCC 4.0.1 (Apple Inc. build 5465)] on darwin Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) When just starti...

How can I launch an instance of an application using Python?

I am creating a Python script where it does a bunch of tasks and one of those tasks is to launch and open an instance of Excel. What is the ideal way of accomplishing that in my script? ...

Retrieving python module path

I want to detect whether module has changed. Now, using inotify is simple, you just need to know the directory you want to get notifications from. How do I retrieve a module's path in python? ...

Is it possible to get the value of an item contained in Django's "changed_data" list?

I have the following code in my Django application: if 'book' in authorForm.changed_data: #Do something here... I realize Django can tell me which values have changed in my form by utilizing the "changed_data" list object, but I'd like to know the new values of the fields that have changed. Any thoughts? ...

Is there something between a normal user account and root?

I'm developing an application that manages network interfaces on behalf of the user and it calls out to several external programs (such as ifconfig) that requires root to make changes. (Specifically, changing the IP address of a local interface, etc.) During development, I have been running the IDE as root (ugh) and the debugger as root ...

Python: using a recursive algorithm as a generator

Recently I wrote a function to generate certain sequences with nontrivial constraints. The problem came with a natural recursive solution. Now it happens that, even for relatively small input, the sequences are several thousands, thus I would prefer to use my algorithm as a generator instead of using it to fill a list with all the sequen...

I need a really good reason to use Python.

I have been trying to make a case for using Python at my work. We use C# and ASP.NET for basically all of our development. 80% or more of our projects are web applications. It seems natural that we would look at some of the nice dynamic web languages (Ruby, Python, etc), and with things like IronRuby and IronPython, I started seriously i...

Jython 2.2.1, howto move a file? shutils.move is non-existant!

'''use Jython''' import shutil print dir(shutil) There is no, shutil.move, how does one move a file with Jython? and while we at it, how does one delete a file with Jython? ...