python

How to enlarge subplot matplotlib?

I currently have two subplots. Note: this is in matplotlib v0.99.3 on Mac OS X 10.6.x I have an event-handler that when one of the subplots are clicked, it prints something. This is only a temporary place holder. What I want to happen is when the subplot is clicked, I want it to take up the whole figure (delete the other subplot and max...

How do I search a range for a single integer?

My Python code generates a random number between 0 and 35 and stores that number as 'random'. I am looking to compare 'random' against several ranges of numbers to determine which of three groups it falls into and assign another value to 'winning' based on which group 'random' is in. The groups are: 0-16, 16-34, and 34-36. 'winning' alwa...

Django Error: Unhandled Exception

Hi, after running: "python manage.py runserver", I'm getting the error: Validating models... Unhandled exception in thread started by <function inner_run at 0xc942a8> File "/home4/usr/.local/lib/python/Django-1.2.1-py2.4.egg/django/core/management/commands/runserver.py", line 48, in inner_run self.validate(display_num_errors=True) File...

Installing Python extensions on OS X, missing MacOSX10.4u.sdk error

I'm attempting to install various python extensions on OS X (10.6.4), with a python.org python (Python 2.6.4 (r264:75821M, Oct 27 2009, 19:48:32)). Consistently running into a problem on the gcc step. Here's a sample from compiling Cython (btw, I'm attempting to install Cython in order to install lxml): In file included from /usr/includ...

How do I eliminate Windows consoles from spawned processes in Python (2.7)?

I'm using python 2.7 on Windows to automate batch RAW conversions using dcraw and PIL. The problem is that I open a windows console whenever I run dcraw (which happens every couple of seconds). If I run the script using as a .py it's less annoying as it only opens the main window, but I would prefer to present only the GUI. I'm involvi...

vba-style compiler/gui for python

does anyone know if there a vba style compiler/gui for python. i am using the regular IDLE and it is difficult to navigate from function to function. with the VBA editor you are able to skip from function to function with a listbox. does anyone know if such a thing exists for python? ...

How to setup amazon s3 module on ubuntu?

I am looking at the readme and there isn't any instructions on how to install it locally on my ubuntu machine (curious, is it different on a mac os?) http://github.com/boto/boto/blob/master/README ...

when updating an object, what do I call? session.add is for adding, where is update?

http://www.sqlalchemy.org/docs/reference/orm/sessions.html I don't see anything for updating an object that was just retrieved from the database using: q = session.query(products) for p in q: p.blah = 'hello' sesion.???? session.commit() ...

split multiple MeSH terms that i extracted from medline formate of PubMed site

How I could split MeSH terms -primary MH(*) from Secondary in python for lots of articles? MH - Female MH - Humans MH - Middle Aged MH - Obesity, Abdominal/*epidemiology MH - Polysomnography MH - Risk Factors MH - Sleep Deprivation/*epidemiology/physiopathology MH - Sleep Stages MH - Sleep, REM MH - Sweden/epidemiology MH - T...

python: getting substring within element in list

row=['alex','liza','hello **world**','blah'] i do i get everything in row[2] that is between the ** characters? ...

Python introspection: description of the parameters a function takes.

Hello, I'm wondering if there is a tool similar to dir() for modules that will tell me what parameters a given function takes. For instance, I would like to do something like dir(os.rename) and have it tell me what the parameters are documented as so that I can avoid checking the documentation online, and instead use only the python...

Repeat string to certain length

What is an efficient way to repeat a string to a certain length? Eg: repeat('abc', 7) -> 'abcabca' Here is my current code: def repeat(string, length): cur, old = 1, string while len(string) < length: string += old[cur-1] cur = (cur+1)%len(old) return string Is there a better (more pythonic) way to do this...

Flash video record on website tutorial

I wanted to make a website that would let users record a small video message through their broswer and save it to my website. As I have never used flash, i wanted to know what softwares would be required and what programming languages would I need? I mean, what should I go about learning to implement such a site. I would prefer open-sou...

wxPython wx.Close create runtime error

When I try to call self.Close(True) in the top level Frame's EVT_CLOSE event handler, it raises a RuntimeError: maximum recursion depth exceeded. Here's the code: from PicEvolve import PicEvolve import wx class PicEvolveFrame(wx.Frame): def __init__(self, parent, id=-1,title="",pos=wx.DefaultPosition, size=wx.DefaultSize,...

Extracting tokens where some are optional

I need to parse out time tokens from a string where the tokens are optional. Samples given: tt-5d10h tt-5d10h30m tt-5d30m tt-10h30m tt-5d tt-10h tt-30m How can I, in Python, parse this out preferably as the set (days, hours, minutes)? ...

Different instance-method behavior between Python 2.5 and 2.6

Trying to change the __unicode__ method on an instance after it's created produces different results on Python 2.5 and 2.6. Here's a test script: class Dummy(object): def __unicode__(self): return u'one' def two(self): return u'two' d = Dummy() print unicode(d) d.__unicode__ = d.two print unicode(d) print d._...

Python Path import problems.

I added a folder to my PYTHONPATH where I can put all of my Django Apps. I print sys.path, and everything looks good, the folder I want is there. However, when I go to import a module, it tells me that there's no module by that name. All the site-packages modules work fine. In all of my Django apps, there's an "__init__.py" like there's ...

Python Application does nothing

This code stopped doing anything at all after I changed something that I no longer remember #Dash Shell import os import datetime class LocalComputer: pass def InitInformation(): Home = LocalComputer() #Acquires user information if (os.name == "nt"): Home.ComputerName = os.getenv("COMPUTERNAME") Home.Us...

Need to create thumbnail, how to ensure proportions and set fixed width?

I want to create a thumbnail, and the width has to be either fixed or no bigger than 200 pixels wide (the length can be anything). The images are either .jpg or .png or .gif I am using python. The reason it has to be fixed is so that it fits inside a html table cell. ...

global variables in python

class AlphaBetaAgent(MultiAgentSearchAgent): def action(self,gamestate): self.alpha= -9999 self.beta = 9999 def abc(gamestate, depth, alpha, beta): def bvc(gamestate, depth, alpha, beta): return abc(gamestate, 0, alpha, beta) I am calling the getAction function which itself calling the abc funct and abc funct...