python

Generating Combinations in python

I am not sure how to go about this in Python, if its even possible. What I need to do is create an array (or a matrix, or vector?) from 3 separate arrays. Each array as 4 elements as such, they return this: Class1 = [1,2,3,4] Class2 = [1,2,3,4] Class3 = [1,2,3,4] Now what I would like to do is return all possible combinations of thes...

All in one Django/Python editor

Hi all, I know this is probably a question that is asked a ton on here but I haven't been able to find exactly what I'm looking for. I'm a JAVA developer that is learning Python and Django and I'm looking for a good development environment. I would like to be able to edit python code, css, html and javascript all in the same editor i...

why my code stop in secound while loop ?

#hello , i wounder why my code keep stoping at the secound while loop and doesn't do anything print"*******************************" a = 0 deg_list =[] deg_list_a=[] deg_list_b=[] deg_list_c=[] degree=input("Enter the students Degree:") while a<=degree: deg_list.append(degree); degree=input("Enter the students Degree:") print "D...

Using Python or Java, what would be the best way to create charts?

I've been searching and found jFreeChart, Python Google Chart and matplotlib. Searching here I also found CairoPlot. I've heard I might be able to use OpenOffice to do it too. Is the API easy to use? Or would it be simpler to stick to one of those libraries? I have more experience with Java, but I've read most of Dive Into Python 3 and ...

Test if lists share any items in python

I want to check if any of the items in one list are present in another list. I can do it simply with the code below, but I suspect there might be a library function to do this. If not, is there a more pythonic method of achieving the same result. In [78]: a = [1, 2, 3, 4, 5] In [79]: b = [8, 7, 6] In [80]: c = [8, 7, 6, 5] In [81...

Python: Install 2.5.5?

Here is the page I found to get 2.5.5: http://www.python.org/download/releases/2.5.5/ (I need it for Google App Engine.) All I see is source files, not an installer. I'm not entirely sure how to build them on my windows machine. What do I do? (Open in Visual Studio, build there?) Or is there an installer I can use? ...

Passing strings in value field in pyscopg2

Sorry this is a very newbie question. When I'm trying to pass a tuple into an insert statement the quotations seem to disappear. line=[0, 1, 3000248, 'G', 'T', 102, 102, 60, 25] SNPinfo = tuple(line) curs.execute("""INSERT INTO akr (code, chrID, chrLOC, refBase, conBase, \ consqual, SNPqual, maxMapqual, numbReadBases) \ VALUES (%s,%...

Why declare unicode by string in python?

I'm still learning python and I have a doubt: In python 2.6.x I usually declare encoding in the file header like this (as in PEP 0263) # -*- coding: utf-8 -*- After that, my strings are written as usual: a = "A normal string without declared Unicode" But everytime I see a python project code, the encoding is not declared at the he...

OAuth authentication fails for google data APIs for hosted domains using gdata

Hello world! I'm creating a django app that creates a calendar and a google docs folder for the users, and uses the API to insert events and add documents. A few months ago, it worked nice enough; now I'm doing a major refactoring of my code and, while testing the aforementioned components, I discovered that they don't work anymore! Whe...

In python, when using select.select on socket objects, how should I handle sockets that end up on the error list?

read, write, error = select.select(sockets, sockets, sockets, 60.0) What is recommended if something ends up in the error list? ...

Access Gmail atom feed using OAuth

Hi, I'm trying to grab the Gmail atom feed from a python application using OAuth. I have a working application that downloads the Google Reader feed, and I think it should simply be a matter of changing the scope and feed URLs. After replacing the URLs I can still successfully get Request and Access tokens, but when I try to grab the fee...

python curses.newwin not working

I'm learning curses for the first time, and I decided to do it in python because it would be easier than constantly recompiling. However, I've hit a hitch. When I try to update a seccond window, I get no output. Here's a code snippet: import curses win = curses.initscr() curses.noecho() curses.cbreak() curses.curs_set(0) field = curses...

Google App Engine: UnicodeDecode Error in bulk data upload

I'm getting an odd error with Google App Engine devserver 1.3.5, and Python 2.5.4, on Windows. A sample row in the CSV: EQS,550,foobar,"<some><html><garbage /></html></some>",odp,Ti4=,http://url.com,success The error: ..................................................................................................................[E...

Comparing if datetime.datetime exists or None

I'm running a small app on Google App Engine with Python. In the model I have property of of type DateTimeProperty, which is datetime.datetime. When it's created there is no value, None. I want compare if that datetime.datetime is None, but I can't. if object.updated_date is None or object.updated_date >= past: object.updated_date = n...

Splitting a hex string into a list in Python - How?

If I have this string: hexstring = '001122334455' How can I split that into a list so the result is: hexlist = ['00', '11', '22', '33', '44', '55'] I can't think of a nice, pythonic way to do this :/ ...

Closed source projects and scripting languages

Hello, I've considered making a closed source project, but if I made it then I'd want to make it in Ruby. Ruby is interpreted though. Other similar languages to Ruby include Python and Perl. How would you best distribute your code without giving away all the logic(at least easily readable)? And what about meta programming? Do obfuscaters...

Mac OS X Python GUI Administrator Prompt

I have an OS X Python application that uses wxPython for it's GUI controls. I'm looking to prompt the user for administrative rights (akin to using the Authorization Service API in Objective-C) before starting a network service. The closest library I have found is Bob Ippolito's Authorization library but it is fairly outdated and has co...

Use of a deprecated module 'string'

Hi all. I just ran pylint on my code and it shows up this message: Uses of a deprecated module 'string' I am using the module string for join / split mainly. >>> names = ['Pulp', 'Fiction'] >>> import string >>> fullname = string.join(names) >>> print fullname Pulp Fiction Above is an example. In my code I have to make use of split...

Can't get Beaker cache working

Hi everyone, I'm trying to use Beaker's caching library but I can't get it working. Here's my test code. class IndexHandler(): @cache.cache('search_func', expire=300) def get_results(self, query): results = get_results(query) return results def get(self, query): results = self.get_results(query) ...

WxPython custom styled controls

I'd need to make a new style for buttons and text entry controls. It should look something like Is there a way to do this? ...