python

Aptana Studio is opening but not ever closing a python.exe process

I am developing a small testing website using Django 1.2 in Aptana Studio build 2.0.4.1268158907. I have a Django project that I test by running the command "runserver 8001" on my project. This command runs the project on a small server that comes with Django. However the problem arises that every time I run this command Aptana opens ...

Python PEP8: Blank lines convention.

Hi. I am interested in knowing what is the Python convention for new lines between the program? For example, consider this: import os def func1(): def func2(): What should be the ideal new line separation between: the import modules and the functions? the functions themselves? I have read PEP8, but I wanted to confirm the abov...

taking intersection of N-many lists in python

what's the easiest way to take the intersection of N-many lists in python? if I have two lists a and b, I know I can do: a = set(a) b = set(b) intersect = a.intersection(b) but I want to do something like a & b & c & d & ... for an arbitrary set of lists (ideally without converting to a set first, but if that's the easiest / most eff...

regex help using repreated groups

I'm trying to match rc-update -s output in python. m = re.match(r"^\s*(\w+)\s*\|{\s*(\w+)\s*}*$", " network | level1 level2 leveln ") but m is always None the hard part for me is getting the regex to match the n levels. I thought that using {}* would match the n levels, but as soon as I add the {} nothing matches. thanks. ...

Is it possible to increase the response timeout in Google App Engine?

On my local machine the script runs fine but in the cloud it 500 all the time. This is a cron task so I don't really mind if it takes 5min... < class 'google.appengine.runtime.DeadlineExceededError' >: Any idea whether it's possible to increase the timeout? Thanks, rui ...

Split based by a-z character in an alphanumeric string in python

I have strings like "5d4h2s", where I want to get 5, 4, and 2 from that string, but I also want to know that 5 was paired with d, and that 4 was paired with h, etc etc. Is there an easy way of doing this without parsing char by char? ...

Pinging servers in Python

In Python, is there a way to ping a server through ICMP and return TRUE if the server responds, or FALSE if there is no response? ...

Python unicode Decode Error SUDs

OK so I have # -*- coding: utf-8 -*- at the top of my script and it worked for being able to pull data from the database that had funny chars(Ñ ,Õ,é,—,–,’,…) in it and store that data into variables...but I have run into other problems, see I pull my data, organize it, and then dump it into a variables like so: title = product[1] Wher...

Python parse comma seperated number into int

Possible Duplicate: How do I use Python to convert a string to a number if it has commas in it as thousands separators? How would I parse the string 1,000,000 (one million) into it's integer value in Python? ...

hosting simple python scripts in a container to handle concurrency, configuration, caching, etc.

My first real-world Python project is to write a simple framework (or re-use/adapt an existing one) which can wrap small python scripts (which are used to gather custom data for a monitoring tool) with a "container" to handle boilerplate tasks like: fetching a script's configuration from a file (and keeping that info up to date if the ...

Accessing relative path in Python

Hi, I'm running a Mac OS X environment and am used to using ~/ to provide the access to the current user's directory. For example, in my python script I'm just trying to use os.chdir("/Users/aaron/Desktop/testdir/") But would like to use os.chdir("~/Desktop/testdir/") I'm getting a no such file or directory error when trying to ...

Windows path in python

Hi all. What is the best way to represent a windows directory, for example "C:\meshes\as"? I have been trying to modify a script but it never works because I can't seem to get the directory right, I assume because of the '\' acting as escape character? Thanks, Gareth ...

getting smallest of coordinates that differ by N or more in Python

suppose I have a list of coordinates: data = [ [(10, 20), (100, 120), (0, 5), (50, 60)], [(13, 20), (300, 400), (100, 120), (51, 62)] ] and I want to take all tuples that either appear in each list in data, or any tuple that differs from all tuples in lists other than its own by 3 or less. How can I do this efficiently in Pyt...

built in function for computing overlap in Python

is there a built in function to compute the overlap between two discrete intervals, e.g. the overlap between [10, 15] and [20, 38]? In that case the overlap is 0. If it's [10, 20], [15, 20], the overlap is 5. thanks. ...

Django or Drupal, which one should I use that suits best my needs ?

Hello, I want to learn and use Drupal or Django for the following: dynamic web sites, medium database, multi-level users, paypal integration, content managment, speed (developing), security I like MVC, ORM and object-oriented prg. Which is better to jump into ? Which one is more mature, powerful, understandable, object-oriented an...

Dynamically adding @property in python

I know that I can dynamically add an instance method to an object by doing something like: import types def my_method(self): # logic of method # ... # instance is some instance of some class instance.my_method = types.MethodType(my_method, instance) Later on I can call instance.my_method() and self will be bound correctly and ever...

CherryPy configuration tools.staticdir.root problem

Hi there, How can I make my static-file root directories relative to my application root folder (instead of a hard-coded path)? In accordance with CP instructions (http://www.cherrypy.org/wiki/StaticContent) I have tried the following in my configuration file: tree.cpapp = cherrypy.Application(cpapp.Root()) tools.staticdir.root = cpap...

Python form POST using urllib2 (also question on saving/using cookies)

I am trying to write a function to post form data and save returned cookie info in a file so that the next time the page is visited, the cookie information is sent to the server (i.e. normal browser behavior). I wrote this relatively easily in C++ using curlib, but have spent almost an entire day trying to write this in Python, using ur...

Which method can I override for cleanup task when a Tkinter.Tk window in Python?

Hello. I created: class MainGUI(Tkinter.Tk): # some overrides # MAIN gui = MainGUI(None) gui.mainloop() But I need to do some cleanup when the window is closed by the user. Which method in Tkinter.Tk can I override? ...

gtk+ signal emitted when window/dialog is "presented"

Is there a signal that is emitted when a window/dialog is presented in GTK+? Example: when issuing this command to the GTK widget dialog: dialog.present() is there a resulting signal? Or is there any signal that denotes the "showing" of a window/dialog? ...