python

Is Python (Django) experience professionaly comparable to Ruby on Rails?

I ask this because there seems to be a few more jobs available (at least by telecommute) in RoR. If an employer sees significant Python/Django experience on a resume, would it be plausible to believe that the developer would be able quickly learn Rails? ...

Deleting already printed in Python

For practice, I'm trying to do some stuff in Python. I've decided to make a simple hangman game - I'm not making a GUI. The game would start with a simple input(). Now, I'd like next line to, beside asking for input, to delete the hidden word. I've tried using \b (backspace character), but it's not working. Something like: word = input(...

In Django, how do I set the default so that every model is created with INNODB?

Right now, Django defaults to MYISAM...but I want to change it so that everytime I create a new table it is innodb. ...

Trying to install Django via Macports on Leopard

I have Python 2.6 & 3.1 installed on Leopard via mac ports with no problems. I want to install Django 1.2 via mac ports for Python 2.6, but a google search of how to do it seems to point me in the wrong direction. Can anyone point me in the right direction? Thanks again..... ...

Find root of implicit function in Python

I have an implicit function, for example: f(x,y) = x**y + y**y - 3*x I want to solve the root on a meshgrid. So f(x,y) = 0 Drawing the solution is easy: x = linspace(-2,2,11) y = linspace(-2,2,11) (X,Y) = meshgrid(x,y) A = X**Y + Y**Y - 3*X contour(X,Y,A,0) This works great, I have a drawing of the curve I need, however I would l...

Find and replace string values in Python list

Hi! I got this list looking something like this words = ['how', 'much', 'is[br]', 'the', 'fish[br]', 'no', 'really'] What I would like is to replace the [br] with some fantastic value similar to <br /> and thus getting a new list looking like this words = ['how', 'much', 'is<br />', 'the', 'fish<br />', 'no', 'really'] I've labora...

Using an StringIO object for holding uu.encode/uu.decode data

Hello, I would like to do the following: import StringIO, uu my_data = StringIO.StringIO() # this is a file-like object uu.encode(in_file, my_data) # do stuff with my data (send over network) uu.decode(my_data, out_file) # here I finally write to disk The above code works. However, if I implement the previous step as a property in an...

How to write python web service server WSDL?

All the stuff I am seeing points me towards writing clients. ...

Matplotlib: one line, plotted against two related x axes in different units?

I have one y variable, which I am trying to plot against two related x axes, on the top and bottom of the figure (e.g. y="number of things in cube", x1="side length of cube", x2="volume of cube"). I have y, x1, x2 in numpy arrays. The relationship between my x1 and x2 is one-to-one and monotonic, but not simple, and they increase in diff...

Find MacOSX version from Python

Currently I am using this: def _get_mac_ver(): import subprocess p = subprocess.Popen(['sw_vers', '-productVersion'], stdout=subprocess.PIPE) stdout, stderr = p.communicate() return stdout.strip() Is there a better version (eg: by using built-in Python API)? >>> print _get_mac_ver() 10.6.3 Note: I tried os.uname()[2...

[python] Passing all arguments of a function to another function

I want to pass all the arguments passed to a function(func1) as arguments to another function(func2) inside func1 This can be done with *args, *kwargs in the called func1 and passing them down to func2, but is there another way, Orignially def func1(*args, **kwargs): func2(*args, **kwargs) but if my func1 signature is def func1...

How to layout all children of a wxPanel?

I have a wxPython application which allows the users to select items from menus that then change what is visible on the screen. This often requires a recalculation of the layout of panels. I'd like to be able to call the layout of all the children of a panel (and the children of those children) in reverse order. That is, the items wit...

EDI X12 Templates in Python (Most likely django or jinja) (w/ sqlalchemy)

My Case: I'm working on a system that will need to create various X12 files for health care (insurance) transactions and inquiries (Specifically 270 Eligibility and 837 Claim). I know there are good tools out there (pyx12 specifically) for converting between XML and X12, and actually I've gone as far as importing some components from ...

How do I build a flexible counter with 1000+ rows but few reads in Google App Engine?

I have a list of users that only administrators can see (= few reads). This list also displays a count of the number of users in the datastore. Because the list could grow larger than 1000 my first thought was to avoid a normal count() and instead use a sharded counter. However, the problem is that the admins also have access to various...

OSError on uploading files in Django

While trying to send form with image field in it I'm getting : Exception Type: OSError at /user/register/ Exception Value: (13, 'Permission denied') Of course first thing I've checked were the permissions to my folders, and just in case set them to 777 on the whole path from '/'. Still nothing. So I've tried adding parameters to setting...

Highlight selected Tab - Python webpage

I am trying to develop my first python web project. It have multiple tabs (like apple.com have Store, iPhone, iPad etc tabs) and when user click on any tab, the page is served from server. I want to make sure that the selected tab will have different background color when page is loaded. Which is a best way to do it? JavaScript/CSS/Direc...

Using enum properties in PyGTK/GObject

This tutorial on using GObject in Python only covers using a property of type gobject.TYPE_FLOAT. I've adapted it to use an enumerated type: import pygtk pygtk.require('2.0') import gobject FUEL_NONE = 0 FUEL_SOME = 1 FUEL_FULL = 2 class Car(gobject.GObject): __gproperties__ = { 'fuel' : (gobject.TYPE_ENUM, ...

Python: If an iterator is an expression, is it calculated every time?

Take the following example: >>> for item in [i * 2 for i in range(1, 10)]: print item 2 4 6 8 10 12 14 16 18 Is [i * 2 for i in range(1, 10)] computed every time through the loop, or just once and stored? (Also, what is the proper name for that part of the expression?) One reason I would want to do this is that I only want the ...

PyUnit with a variable number of tests

What I would like to do, is create a folder, where people can put in a file for testing, and have pyunit automatically expand in order to run the test as a separate test. Currently, what I'm doing is: class TestName(unittest.testcase): def setUp(self): for file in os.listdir(DIRECTORY): # Setup Tests def te...

Python question relating to dated values in a csv file

I am loading a data file with dated data into a csv.DictReader The data looks like this: date, weight, blood_pressure, sugar_level 1/1/01, 120.1, 100.1, 25.2 2/1/01, 130.1, 102.1, 26.2 3/1/01, 110.1, 120.1, 24.2 4/1/01, 130.1, 130.1, 28.2 5/1/01, 160.1, 104.1, 27.0 6/1/01, 150.5, 100...