python

What are my options for 3D plotting in Python?

It also must be redistributable. ...

Problem loading Django fixture: IntegrityError: (1062, "Duplicate entry '4' for key 'user_id'")

I used the following commands to generate 2 fixtures: ./manage.py dumpdata --format=json --indent=4 --natural auth.User > fixtures/user.json ./manage.py dumpdata --format=json --indent=4 --natural --exclude=contenttypes --exclude=auth > fixtures/full.json I've got the following fixture named user.json: [ { "pk": 4, ...

numpy matrix multiplication

I am trying to figure out how to do a kind of scalar matrix multiplication in numpy. I have a = array(((1,2,3),(4,5,6))) b = array((11,12)) and i want to do a op b to result in array(((1*11,2*11,3*11),(4*12,5*12,6*12)) right now I am using the following expression c= a * array((b, b, b)).transpose() It seems like there must...

Jinja2 PackageLoader on google app engine

I want to use jinja2.PackageLoader on Google App engine, but that appears to depend on pkg_resources, which wasn't added until Python 2.6. Am I Out of luck? ...

Best data structure for dictonary in Java(Also Python)

Hi all, Here is my requirement: Input: Random String of sufficiently long ex: fdjhkajajkfdj Output: fdj has a 2 occurences and separated by x chars I want to put all three letter words in an array and check if they are the same Eg: a[0] = fdj a[1] = djh a[2] = jhk a[3] = hka a[4] = kaj . . . a[n] =fdj My answer is a[0] and a[n] ...

How to install both Python 2.x and Python 3.x in Windows 7

I do most of my programming in Python 3.x on Windows 7, but now I need to use the Python Imaging Library (PIL), ImageMagick, and wxPython, all of which require Python 2.x. Can I have both Python 2.x and Python 3.x installed in Windows 7? When I run a script, how would I "choose" which version of Python should run it? Will the aforementi...

swing component in pyqt

Is there a way to run a swing component through a pyqt widget? I'd like to write a small project using pyqt, but there's a java library that draws to a JPanel-inherited panel, and it would be really convenient to be able to embed one into the other. I know I could use jython and qtjambi, but I was curious if there was an alternative su...

Problem With openPanelDidEnd in PyObjC in 10.6

The following code which worked fine under OS X 10.5 now fails on 10.6: @IBAction def addButton_(self, sender): panel = NSOpenPanel.openPanel() panel.setCanChooseDirectories_(YES) panel.setAllowsMultipleSelection_(YES) try: panel.beginSheetForDirectory_file_modalForWindow_modalDelegate_didEndSelector_contextI...

Python; reading file and finding desired text

Need to create a function with two params, a filename to open and a pattern. The pattern will be a search string. Eg. the function will open sentence.txt that has something like "The quick brown fox" (can possibly be more than one line) The pattern will be "brown fox" So if found, as this will be, it should return a line number and i...

AMQP implementations with Celery

I wanted to get your opinions on the merits of different AMQP implementations to be used with celery. I am looking particularly at message prioritization and job queue sizes. What are your thoughts? ...

How to configure ipy_user_conf.py to get IPython to to start with the right IDLE set as editor?

64-bit Vista Python 2.6 IPython 0.10 Also have Python 2.7 and 3.1 My ipy_user_conf.py has example lines showing how to set an editor. I've tried ipy_editors.idle() but [C:Python26/Scripts] |4>ed xxx.py Editing... > C:\Python26\lib\idlelib/idle.py "xxx.py" opens the IDLE for Python 3.1, and doesn't open xxx.py. I next imitated a s...

Smart Loop List Creation in Python for Django Choice fields

So. The following isn't very 'smart' ;) MONTHS = ( ('Jan', 'Jan'), ('Feb', 'Feb'), ('Mar', 'Mar'), ('Apr', 'Apr'), ('May', 'May'), ('Jun', 'Jun'), ('Jul', 'Jul'), ('Aug', 'Aug'), ('Sep', 'Sep'), ('Oct', 'Oct'), ('Nov', 'Nov'), ('Dec', 'Dec'), ) YEARS = ( ('1995', '1995'), ('1996'...

Python for indexing and searching using a cluster?

After an unfortunate misadventure with MySQL, I finally gave up on using it. What I have? Large set of files in the following format: ID1: String String String String ID2: String String String String ID3: String String String String ID4: String String String String What I did? Used MySQL on a powerful machine to import everything ...

Ruby or Python instead of PHP?

I'm considering learning a new language as an alternative to PHP. I'm considering Python and Ruby. Which one is a better language based on the following four criteria, and any other qualifiers you may have? Which is more stable? Which is more scaleable? Which is more secure? Which is easier to learn? EDIT: Keeping the original quest...

How to find dates in the sentence using NLP, RegEx in Python

Hi Can anyone suggest me some way of finding and parsing dates (in any format, "Aug06", "Aug2006", "August 2 2008", "19th August 2006", "08-06", "01-08-06") in the python. I came across this question, but it is in perl... http://stackoverflow.com/questions/3445358/extract-inconsistently-formatted-date-from-string-date-parsing-nlp Any ...

Encrypt string in Python

I need to encrpyt a small string in Python. Is it possible to use a secret key to encrypt the string? Is there a good way to do this and achieve a reasonable encpryption level using only Python libraries? Could you show me how to do this? My knowledge about cryptography is quite basic. : Thank you. ...

What's wrong with my try: except: syntax?

Choking code: while port < 0 or port > 65535: try: port = int(raw_input("Enter port: ") except ValueError: print "Invalid port number." Result: File "/Users/.../Documents/.../CS 176A/TCPServer.py", line 10 except ValueError: ^ SyntaxError: invalid syntax ...

Python unicode popen or Popen error reading unicode

Hello, I have a program that generates the following output: ┌───────────────────────┐ │10 day weather forecast│ └───────────────────────┘ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ Tonight Sep 27 Clear 54 0 % Tue Sep 28 Sunny 85/61 0 % Wed...

python multiple inheritance from different paths with same method name

With the following code sample, can super be used, or C has to call A.foo and B.foo explicitly? class A(object): def foo(self): print 'A.foo()' class B(object): def foo(self): print 'B.foo()' class C(A, B): def foo(self): print 'C.foo()' A.foo(self) B.foo(self) ...

how to install python distutils

I just got some space on a VPS server(running on ubuntu 8.04), and I'm trying to install django on it. The server has python 2.5 installed, but I guess its non standard installation. When I run install script for django, I get amitoj@ninja:~/Django-1.2.1$ python setup.py install Traceback (most recent call last): File "setup.py", line...