python

VPython in Eclipse - thinks it has the wrong architecture type.

Evening, So I've recently installed VPython on my MacBook (OS X, Snow Leopard) - and it works absolutely fine in IDLE and from the command line (interactive mode). However, eclipse has issues. Firstly it couldn't find it (which is a bit of an issue actually with all these 'easy install' python modules - when they don't tell you where t...

How to reproduce System.Security.Cryptography.SHA1Managed result in Python

Here's the deal: I'm moving a .NET website to Python. I have a database with passwords hashed using the System.Security.Cryptography.SHA1Managed utility. I'm creating the hash in .NET with the following code: string hashedPassword = Cryptographer.CreateHash("MYHasher", userInfo.Password); The MYHasher block looks like this: <add al...

Writing Strings to files in python

I'm getting the following error when trying to write a string to a file in pythion: Traceback (most recent call last): File "export_off.py", line 264, in execute save_off(self.properties.path, context) File "export_off.py", line 244, in save_off primary.write(file) File "export_off.py", line 181, in write variable.writ...

Help finding longest non-repeating path through connected nodes - Python

I've been working on this for a couple of days now without success. Basically, I have a bunch of nodes arranged in a 2D matrix. Every node has four neighbors, except for the nodes on the sides and corners of the matrix, which have 3 and 2 neighbors, respectively. Imagine a bunch of square cards laid out side by side in a rectangular area...

Python or Ruby for webbased Artificial Intelligence?

A new web application may require adding Artificial Intelligence (AI) in the future, e.g. using ProLog. I know it can be done from a Java environment, but I am wondering about the opportunities with modern web languages like Ruby or Python. The latter is considered to be "more scientific" (at least used in that environment), but using Go...

pyenchant RPM for alt-install of python2.6. ELF class error

I know what my problem is with this issue, but I'm a little confused about how to best go about fixing it. I have a RHEL 5.4 system, with Python2.6 alt-installed (via the geekymedia RPMS). everything seems to be working. As I tweak a spec file, I'm able to build out RPMs to work with this new Python install. I'm building all of my RP...

Number Sequence in MySQL

In Python if I wanted a sequence from 0 - 9 (inclusive) I would use xrange(0,10) . Is there a way I can do this in MySQL? ...

Python.expat can't parse XML file with bad symbols. How to go around?

I'm trying to parse an XML file (OSM data) with expat, and there are lines with some Unicode characters that expat can't parse: <tag k="name" v="абвгдежзиклмнопр�?туфхцчшщьыъ�?ю�?�?БВГДЕЖЗИКЛМ�?ОПРСТУФХЦЧШЩЬЫЪЭЮЯ" /> <tag k="name" v="Cin\x8e? Rex" /> (XML file encoding in the opening line is "UTF-8") The file is quite old, and there...

Variable alpha blending in pylab

How does one control the transparency over a 2D image in pylab? I'd like to give two sets of values (X,Y,Z,T) where X,Y are arrays of positions, Z is the color value, and T is the transparency to a function like imshow but it seems that the function only takes alpha as a scalar. As a concrete example, consider the code below that attempt...

SelfReferenceProperty vs. ListProperty Google App Engine

Hi All, I am experimenting with the Google App Engine and have a question. For the sake of simplicity, let's say my app is modeling a computer network (a fairly large corporate network with 10,000 nodes). I am trying to model my Node class as follows: class Node(db.Model): name = db.StringProperty() neighbors = db.SelfReferen...

Filtering documents against a dictionary key in MongoDB

I have a collection of articles in MongoDB that has the following structure: { 'category': 'Legislature', 'updated': datetime.datetime(2010, 3, 19, 15, 32, 22, 107000), 'byline': None, 'tags': { 'party': ['Peter Hoekstra', 'Virg Bernero', 'Alma Smith', 'Mike Bouchard', 'Tom George', 'Rick Snyder'], 'g...

Django - provide additional information in template

Hi all, I am building an app to learn Django and have started with a Contact system that currently stores Contacts and Addresses. C's are a many to many relationship with A's, but rather than use Django's models.ManyToManyField() I've created my own link-table providing additional information about the link, such as what the address typ...

Exception_Record in python2.5 problem

I'm using Python2.5 & the following code produce 2 errors. Can any body help me? class EXCEPTION_RECORD(Structure): _fields_ = [ ("ExceptionCode", DWORD), ("ExceptionFlags", DWORD), ("ExceptionRecord", POINTER(EXCEPTION_RECORD)), ("ExceptionAddress", LPVOID), ("NumberParameters", DWORD), ...

Pylons error "No object (name: request) has been registered for this thread" with debug = false

I'm unable to access the request object in my Pylons 0.9.7 controller when I set debug = false in the .ini file. I have the following code: def run_something(self): print('!!! request = %r' % request) print('!!! request.params = %r' % request.params) yield 'Stuff' With debugging enabled this works fine and prints out: !!!...

Problems serving static files in CherryPy 3.1

Hi All, I'm having some trouble serving a static XML stylesheet to accompany some dynamically generated output from a CherryPy web app. Even my test case serving a static text file fails. Static file blah.txt is in the /static directory in my application root directory. In my main site file (conesearch.py contains the CherryPy ConeSea...

Frame Buffers wont work with pyglet.

I have this code: def setup_framebuffer(surface): #Create texture if not done already if surface.texture is None: create_texture(surface) #Render child to parent if surface.frame_buffer is None: surface.frame_buffer = glGenFramebuffersEXT(1) glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, surface.frame_buffer) glFramebufferTexture2DEX...

Asynchronous background processes in Python?

I have been using this as a reference, but not able to accomplish exactly what I need: http://stackoverflow.com/questions/89228/how-to-call-external-command-in-python/92395#92395 I also was reading this: http://www.python.org/dev/peps/pep-3145/ For our project, we have 5 svn checkouts that need to update before we can deploy our applic...

querying mysql and loading result into a list in a pythoncard gui

so heres whats up. I'm making a little program for myself that 1)takes a name of a row from a drop down box and makes a query with it and 2) displays query results into a multi-column list. i have the gui setup i need to sript the drop box with the query names and then have the results go into the list i set up in the gui heres the code...

convert a binary file in a list (python)

Hi all, I'd like to be able to open a binary file, and make a list (kind of array) with all the chars in, like : "\x21\x23\x22\x21\x22\x31" to ["\x21","\x23","\x22","\x21","\x22","\x31"] What would be the best solution to convert it ? Thanks ! ...

Is there a function in C that does the same as raw_input in Python?

Is there a C function that does the same as raw_input in Python? #in Python:: x = raw_input("Message Here:") How can I write something like that in C? Update:: I make this, but i get an error :: #include<stdio.h> #include<string.h> #include "stdlib.h" typedef char * string; int raw_input(string msg); string s; string *d; main(){...