python

Where do download python PIL module from?

Where do I download the python PIL module from? I found some sites but not sure if they can be trusted. This is for my macbookpro. Is effbot the sourcE? ...

Help me with py2exe

I made my program, and tested it in Command Prompt(by entering in the directory). Then I made a set up file, and put the setup file and my program in the same folder. My setup file: from distutils.core import setup import py2exe setup(console=['C:\Python26\test\testprogram.py']) I went to run the setup program in command prompt(by e...

Constructing objects in __init__

I've seen code that looks something like this: class MyClass: def __init__(self, someargs): myObj = OtherClass() myDict = {} ...code to setup myObj, myDict... self.myObj = myObj self.myDict = myDict My first thought when I saw this was: Why not just use self.myObj and self.myDict in the begi...

Opening a website frame or image in python

So i am fairly fluent with python and have used urllib2 and Cookies a lot for website automation. I just stumbled upon the "webbrowser" module which can open a url in your default browser. Im wondering if its possible to select just one object from that url and open that up. Specifically i want to open a "captcha" so that the user can in...

wxPython wxProgressDialog randomly skips

Strange problem - I'm using wxPython version 2.8 with Python version 2.6. I'm inserting thousands of records into a database and using wxProgressDialog.Update to keep up with the status of the process. The code looks like this: (keepgoing, skip) = self.frame.dialog.Update(prog, msg + ...

Hide password when checking config file in git.

Possible Duplicates: What is the best practice for dealing with passwords in github? How can I track system-specific config files in a repo/project? Hi, I would like to hide DATABASE_NAME = '' DATABASE_USER = '' DATABASE_PASSWORD = '' DATABASE_HOST = '' Line 13 to 17 of the default Django settings.py file when checking...

GAE datastore date property auto produce date of 1970

I have datastore Model bellow: class ThisCategory(search.SearchableModel): ancestor = db.ListProperty(db.Key, default=[]) no_ancestor = db.BooleanProperty(default=True) name = db.StringProperty() description = db.TextProperty() last_modified = db.TimeProperty(auto_now=True) #<----- (1970-01-01 15:36:47.987352) in dat...

How can I add a test method to a group of Django TestCase-derived classes?

Hi all, I have a group of test cases that all should have exactly the same test done, along the lines of "Does method x return the name of an existing file?" I thought that the best way to do it would be a base class deriving from TestCase that they all share, and simply add the test to that class. Unfortunately, the testing framework ...

Cumulative summation of a numpy array by index

Assume you have an array of values that will need to be summed together d = [1,1,1,1,1] and a second array specifying which elements need to be summed together i = [0,0,1,2,2] The result will be stored in a new array of size max(i)+1. So for example i=[0,0,0,0,0] would be equivalent to summing all the elements of d and storing the ...

How can I import a python module fuction dynamically?

Assuming def my_function(): is located in my_apps.views I would like to import "my_function" dynamically without using something like exec or eval. Is there anyway to accomplish this. I'm looking to do something similar to: my_function = import_func("my_apps.views.my_function") my_function() ... code is executed ...

Is there any python web app framework that provides database abstraction layer for SQL and NoSQL?

Is it even possible to create an abstraction layer that can accommodate relational and non-relational databases? The purpose of this layer is to minimize repetition and allows a web application to use any kind of database by just changing/modifying the code in one place (ie, the abstraction layer). The part that sits on top of the abstra...

Flickr Gallery API wrapper for Python?

Is there currently a Flickr API wrapper for Python which includes working with galleries? I'm aware of these two wrappers, but neither of them seems to support galleries: http://stuvel.eu/projects/flickrapi http://code.google.com/p/flickrpy/ Is there some wrapper hidden away in the dark corners of the internet or would I have to wri...

numpy.isnan returns TypeError

I do: print "e: ", scaled_target, type(scaled_target) print "f: ", numpy.isnan(scaled_target) which returns e: [0.0 0.0 0.0 0.0] <type 'numpy.ndarray'> f: Traceback (most recent call last): File "./a.py", line 106, in <module> print "f: ", numpy.isnan(scaled_target) TypeError: function not supported for these types, and can't...

Google App Engine Python WebApp framework supported self.error() codes.

Hi! I know we can return errors to requests by calling self.error(http_error_code_here). However, there are some error codes that don't seem to be supported. "Unsupported error code" comes out when I use error code 510. I used http://en.wikipedia.org/wiki/List_of_HTTP_status_codes as a reference for the error codes I am using. What ht...

True = False == True

Possible Duplicate: Why can't Python handle true/false values as I expect? False = True should raise an error in this case. False = True True == False True True + False == True? if True + False: print True True True Again? if str(True + False) + str(False + False) == '10': print True True LOL if True + False...

Avoid OpenERP audittrail bug

I'd like to manage OpenERP user's activity by installing the audittrail module. After creating some rules ( define which user, which object and which activity (create, update..) will be monitored). I update a product to see it works. When I've tried to update a product i got the system error. Seeing the log, I get [2010-08-31 12:53:35,0...

Removing python module installed in develop mode

Hi I was trying the python packaging using setuptools and to test I installed the module in develop mode. i.e python setup.py develop This has added my modules directory to sys.path. Now I want to remove the module is there any way to do this? Thanks in advance ...

Python how to format currency string.

Hi! I have three floats that I want to output as a 2 decimal places string. amount1 = 0.1 amount2 = 0.0 amount3 = 1.87 I want to output all of them as a string that looks like 0.10, 0.00, and 1.87 respectively. How do I do that efficiently? ...

List query with, facebook friends in list ??

In a python based facebook application on GAE, i want to check which friends of current user have "marked" a web page or not. For this i have to run as many DB queries as the number of friends (say 100) I fear this may run into "timeout" because of large no of queries. Google DOCs suggest that "list" queries run in parallel, will this ...

Installing python ssl module on Windows Vista

Hi! I'm running GAE SDK on a windows vista laptop. It keeps reminding me to install the ssl module. I've been having great difficulty on how to do that. I've downloaded the ssl module. I've done 'python setup.py install' in cmd, but it just says "python is not recognized as an internal..." I've added C:\Python2.5.2 to my PATH. Still...