python

re-draw a gtk.Widget (GtkFixed)

hi! I've a GtkFixed area with any widgets into. I want to change coordinates of any components when the user press any button. How can I force to "repaint" de fixed area? I tested "fixed.queue_draw()" but doesn't working (seems) I'm using gkt in Python. (PyGTK) ...

What is the purpose of __str__ and __repr__ in Python?

I really don't understand where are __str__ and __repr__ used in Python. I mean, I get that __str__ returns the string representation of an object. But why would I need that? In what use case scenario? Also, I read about the usage of __repr__ But what I don't understand is, where would I use them? ...

python html form library that supports forms within form (form as a field ) ?

The question says it all, For example, In a contact book if someone has multiple addresses with each address having multiple fields I want to display an "add another address" button. This button would add another address form. (I want one round trip to the server, I do not want javascript or webforms2.) It would be nice if some buil...

Pygame installation on Windows - error: Unable to find vcvarsall.bat

I have a Win7 64 bit dev machine. I've downloaded and installed Python 2.6.6 32bit. I've also downloaded pygame 1.9.1 for python 2.6 and tried to install it. I got: C:\pygame-1.9.1release>setup.py install .... running build_ext building 'pygame._numericsurfarray' extension error: Unable to find vcvarsall.bat What should I do? (I don't...

How to return an apache error page from a wsgi app?

Hi, I have a simple working wsgi app. I can successfully return whatever HTTP status code, headers, and HTML I want. What I would like to do, is that when I'm returning a status code other than '200 OK', for WSGI to let apache fall back to its error handling and display whatever page apache is configured to display according to its 'Err...

A container for accessing contents by 2d/3d coordinates

There are a lot of games that can generally be viewed as a bunch of objects spread out through space, and a very common operation is to pick all objects in a sub-area. The typical example would be a game with tons of units across a large map, and an explosion that affects units in a certain radius. This requires picking every unit in the...

Best practice for keeping Python GAE dependencies in project VCS

At our company we have a very nice system setup for tracking our external packages dependencies in revision control for our current desktop application development (C++/python). We are starting to develop some python only web applications are are looking for recommendations for best practices when there is only python code involved and ...

REST web service in python 3?

Hi, I'm new to the python world and I'm currently in a new project using it. So since we we're there to learn, we chose to start with python 3. Now, we need to make a RESTful web service. After reading a few, I found out that the most used framework for web services is Django... and I also read on the Django website that it does not yet ...

Iterating over N dimensions in Python

I have a map, let's call it M, which contains data mapped through N dimensions. # If it was a 2d map, I could iterate it thusly: start, size = (10, 10), (3, 3) for x in range(start[0], start[0]+size[0]): for y in range(start[1], start[1]+size[1]): M.get((x, y)) # A 3d map would add a for z in ... and access it thusly M.get((...

Storing passwords with python

I have a program I'm writing in python, and I have the need to store some passwords. These passwords will be the passwords to ftp servers, so it's important that they're not just plainly visible to everybody. This also means that I can't store a non-reversible hash of the password like you would on a webserver, because I'm not checking i...

How to detect when Firefox has finished loading a page using Python?

Is it possible to use Python to detect when a web page has finished loading in the Firefox browser? I'm trying to automate some browser tasks using Python and this is the major stumbling block for me. Note that this is for small-scale personal use, not a server farm or anything like that. The Firefox browser is in an open window, so I c...

Embedding Python in an iPhone app

So it's a new millennium; Apple has waved their hand; it's now legal to include a Python interpreter in an iPhone (App Store) app. How does one go about doing this? All the existing discussion (unsurprisingly) refers to jailbreaking. (Older question: Can I write native iPhone apps using Python) My goal here isn't to write a PyObjC app,...

How to display user error in Python

Hi, What is the best way (standard) to display an error to the user in Python (for example: bad syntax, invalid arguments, logic errors)? The method should print the error in the standard error and exit the program. ...

wx.radiobox python

I have the following code : myList =['a','b'] rb=wx.RadioBox(self.panel, -1, "Options :", (0, 0), wx.DefaultSize,myList, 2, wx.RA_SPECIFY_COLS) When it renders first time I see that a choice has been made how can I change the code that when this radibox rendered first time there are no option has been chosen. ...

How to know the path the script the python run?

sys.arg[0] gives me the python script. For example 'python hello.py' returns hello.py for sys.arg[0]. But I need to know where the hello.py is located in full path. How can I do that with python? ...

How should I do rapid GUI development for R and Octave methods (possibly with Python)?

We are a medium-sized academic research lab whose main outputs are new statistical methods for analyzing large datasets. We generally develop in R and MATLAB/Octave. We would like to expand the reach of our work by building simple, wizard-style user interfaces to access our methods, either web-apps like RNAfold or stand-alone applicati...

"%s" % format vs "{0}".format() vs "?" format.

In this post about SQLite, aaronasterling told me that cmd = "attach \"%s\" as toMerge" % "b.db" : is wrong cmd = 'attach "{0}" as toMerge'.format("b.db") : is correct cmd = "attach ? as toMerge"; cursor.execute(cmd, ('b.db', )) : is right thing But, I've thought the first and second is the same. What are the differences between tho...

Books/tutorials that learn by writing an appliaction?

Ok so how I see it the best way to learn is to write a real app so I've been wondering are there any books/tutorials that get you through different languages/frameworks by writing a single app and not by showing some random code snippets. What I mean is that in chapter one we create the app, then in chapter 2 we add some features and inc...

How do I redefine functions in python?

I got a function in a certain module that I want to redefine(mock) at runtime for testing purposes. As far as I understand, function definition is nothing more than an assignment in python(the module definition itself is a kind of function being executed). As I said, I wanna do this in the setup of a test case, so the function to be rede...

In Python, how can I get the correctly-cased path for a file?

Windows uses case-insensitive file names, so I can open the same file with any of these: r"c:\windows\system32\desktop.ini" r"C:\WINdows\System32\DESKTOP.ini" r"C:\WiNdOwS\SyStEm32\DeSkToP.iNi" etc. Given any of these paths, how can I find the true case? I want them all to produce: r"C:\Windows\System32\desktop.ini" os.path.normc...