python

Create and retrieve object list in Python.

Hello, I would like to keep a reference of the objects I've created in one script to use them in another script (without using shelve). I would like something close to : script 1 class Porsche(Car): """ class representing a Porsche """ def __init__(self, color): self.color = color class Porsche_Container: ...

Meta programming in OpenERP

Here a way to develop OpenERP class stock_incoterms(osv.osv): _name = "stock.incoterms" _description = "Incoterms" _columns = { 'name': fields.char('Name', size=64, required=True), 'code': fields.char('Code', size=3, required=True), 'active': fields.boolean('Active'), } _defaults = { 'active': lambda *a: True, } stoc...

Which is most accurate way to distinguish one of 8 colors?

Imagine we how some basic colors: RED = Color ((196, 2, 51), "RED") ORANGE = Color ((255, 165, 0), "ORANGE") YELLOW = Color ((255, 205, 0), "YELLOW") GREEN = Color ((0, 128, 0), "GREEN") BLUE = Color ((0, 0, 255), "BLUE") VIOLET = Color ((127, 0, 255), "VIOLET") BLACK = Color ((0, 0, 0), "BLACK") WHITE = Color ((255, 255, 255), "WHITE")...

Django - dreaded 'iteration over non-sequence'

Hi I'm looking to populate a list of members, based on where their club comes from. This is my code: members = [] if userprofile.countries.count() > 0: for c in userprofile.countries.all(): clubs = Club.objects.filter(location__country = c) for club in clubs: members_list = Member.objects.get_membe...

How do i render a template inside another template?

Hello, I'm new in Django and Python and I'm stuck! It's complicated to explain but I will give it a try... I have my index.html template with an include tag: {% include 'menu.inc.html' %} The menu is a dynamic (http://code.google.com/p/django-treemenus/). The menu-app holds a view that renders menu.inc.html: from django.http import...

Using python ctypes to call io_submit in Linux

I'm trying to call io_submit using python ctypes. The code I'm writing is supposed to work on both 32 and 64-bit Intel/AMD architectures, but here I'll focus on 64 bits. I have defined the following: def PADDED64(type, name1, name2): return [(name1, type), (name2, type)] def PADDEDptr64(type, name1, name2): return [(name1, ty...

Problem requiring lists

The current issue im facing is comes from the following scenario. I have a script that runs a commandline program to find all files of a certain extension within an specific folder, lets call these files File A. Another section of the script runs a grep command through each file for filenames within File A. What would be the best method ...

Create and retrieve object list in Python enhanced.

Hello, This post is the follow-up of my previous post (Create and retrieve object list in Python). I had to modify my code in the following way : script1 #!/usr/bin/python class Porsche: """ class representing a Porsche """ def __init__(self, color): self.color = color def create_porsche(parameter_1, paramete...

Installing Python modules on OSX using easy_install or setup.py install

I am running Snow Leapord 10.6 and trying to install the following python modules: 1) numpy 2) scipy 3) matplotlib I am running into problems because OSX contains two version of Python: 1) /Library/Python/ 2) /System/Library/Frameworks/Python.framework/ It appears that when I execute the following command: sudo easy_install -U {modu...

make python os.chdir follow vim autochdir?

Hi, I use the autochdir option in VIM and I also utilize VIM's built-in Python interface. Is it possible to have the current directory for the built-in Python interpreter follow VIM's autochdir. For example, when I am editing a Python file, VIM's autochdir option puts me in the same directory as the edited file as far as VIM is concern...

Twisted and starpy error (python)

Hi I'm using this: from twisted.web.client import getPage df = getPage(url) # there is some url I'm getting the following error. Please can anyone guide me on this ERROR:twsited:Unhandled error in Deferred: ERROR:twsited:Unhandled Error Traceback (most recent call last): File "/usr/local/lib/python2.6/dist-packages/starpy/manager....

Trouble with receiving data from <form>

HTML: <form enctype="multipart/form-data" action="/convert_upl" method="post"> Name: <input type="text" name="file_name"> File: <input type="file" name="subs_file"> <input type="submit" value="Send"> </form> Python (Google App Engine): if self.request.get('file_name'): file_n...

Google App Engine : Cursor Versus Offset

Do you know which is the best approach for fetching chunks of result from a query? 1.Cursor q = Person.all() last_cursor = memcache.get('person_cursor') if last_cursor: q.with_cursor(last_cursor) people = q.fetch(100) cursor = q.cursor() memcache.set('person_cursor', cursor) 2.Offset q = Person.all() offset = memcache.get('offse...

How add already captured screenshot to wx.BoxSizer?

My Python code: self.images = wx.StaticBitmap(self, id=-1, pos=wx.DefaultPosition, size=(200,150), style= wx.SUNKEN_BORDER) self.hbox = wx.BoxSizer(wx.HORIZONTAL) self.sizer.Add(self.hbox) # my main sizer #in function dinamically captured images bmp = wx.Bitmap...

Python Pythonpath Modules install

I am kind of annoyed by the installation of modules in python and had a lot of trouble with it, so it would be fantastic to find a good solution for it. Heres my issues: PYTHONPATH: How can I tell easy_install/Python where to install my packages? Eventhough I put: /Library/Python/2.6/site-packages in my .bash_profile With: PYTHO...

How do I make wx.TextCtrl multi-line text update smoothly?

I'm working on an GUI program, and I use AppendText to update status in a multi-line text box(made of wx.TextCtrl). I noticed each time there's a new line written in this box, instead of smoothly adding this line to the end, the whole texts in the box just disappear(not in real, just visually) and I have to click the scroll button to che...

Using arbitrary methods or attributes as fields on Django ModelAdmin objects?

Using Django 1.1: The Django admin docs describe using arbitrary methods or attributes on a ModelAdmin object in the list_display class attribute. This is a great mechanism for displaying arbitrary information in the list display for a Model. However, there does not appear to be a similar mechanism for the change form page itself. What ...

Python: shape of a matrix and imshow()

Hello! I have a 3-D array ar. print shape(ar) # --> (81, 81, 256) I want to plot this array. fig = plt.figure() ax1 = fig.add_subplot(111) for i in arange(256): im1 = ax1.imshow(ar[:][:][i]) plt.draw() print i I get this error-message: im1 = ax1.imshow(ar[:][:][i]) IndexError: list index out of range Why do I g...

Windows Live Web Authentication on Google App Engine (GAE) using Python

I'm struggling to get Windows Live Web Authentication running on Google App Engine (GAE) using Python, as I'm quite new to the language. However there are lots of examples for Facebook and Twitter, I was wondering if anyone had come up with a solution for Windows Live yet? ...

(NetworkX) [Python] How can I specify an exact output size for my graph?

http://imgur.com/7wiRw.png The above is the output of my current graph. However, I have yet to manage what I am trying to achieve. I need to output my graph in a larger size so that each node/edge can be viewed with ease. Ive tried nx.draw(G, node_size=size), but that only increases the size of the nodes, not the distance between nodes a...