python

How do I print number of notes to be played?

How do I do the second line in my main argument? def main(): pic= makePicture( pickAFile()) ### It will print the number of notes to be played(which is the number of pixels in the pic divided by 16, why?)### listenToPicture(pic) def listenToPicture(pic): show(pic) w= getWidth(pic) h= getHeight(pic) for i...

Django form INSERTs when I want it to UPDATE

I'm new to Django but I seem to have nearly identical code working on another site. I can update a record in the Django shell, but in view.py the same code insists on INSERTing a new record when I run this form. I have a "DisciplineEvent" object in the model. I let Django create the "id" field for the primary key. I can see the "id" i...

How to write a python script to search a website html for matching links

I am not too familiar with python and have to write a script to perform a host of functions. Basically the module i still need is how to check a website code for matching links provided beforehand. ...

Python: How to refactor this simple list code?

I'm new to Python. Am I doing it right? The goal: Get a bunch of InCart objects from Google App Engine's datastore that corresponds to the current user. Each InCart item has two attributes: InCart.owner and InCart.item Provide the templating engine a set of items in any InCart.item The code: cartEntries = InCart.gql("WHERE ...

Which key value store is the most promising/stable?

I'm looking to start using a key/value store for some side projects (mostly as a learning experience), but so many have popped up in the recent past that I've got no idea where to begin. Just listing from memory, I can think of: CouchDB MongoDB Riak Redis Tokyo Cabinet Berkeley DB Cassandra MemcacheDB And I'm sure that there are mor...

wx.TR_HAS_VARIABLE_ROW_HEIGHT has no effect?

I created a TreeListCtrl in wxPython like following. self.tree = wx.gizmos.TreeListCtrl(self, style = wx.TR_DEFAULT_STYLE | wx.TR_FULL_ROW_HIGHLIGHT | wx.TR_HIDE_ROOT | wx.TR_HAS_VARIABLE_ROW_HEIGHT) As you see i set wx.TR_HAS_VARIABLE_ROW_HEIGHT but...

SQLAlchemy - Problem with an association table and dates in primary join

Hi, I am working on defining my mapping with SQLAlchemy and I am pretty much done except one thing. I have a 'resource' object and an association table 'relation' with several properties and a relationship between 2 resources. What I have been trying to do almost successfully so far, is to provide on the resource object 2 properties: pa...

How to write a python script to manipulate google spreadsheet data

For example i am able to get the feed from the spreadsheet and worksheet id. I want to capture the data from each cell. How do i do that? I.E i am able to get the feed from the worksheet. Now i need to get data(string type?) from each of the cell to make comparison and for input. How exactly can i do that? ...

Sqlalchemy file organization

Does anyone has any insight on organizing sqlalchemy based projects? I have many tables and classes with foreign keys, and relations. What is everyone doing in terms of separating classes, tables, and mappers ? I am relatively new to the framework, so any help would be appreciated. Example: classA.py # table definition and class A defi...

deprecation of apply decorator

Hi! There was a beautiful way to organize class property in frame of one function, by using the apply decorator. class Example(object): @apply def myattr(): doc = """This is the doc string.""" def fget(self): return self._half * 2 def fset(self, value): self._half = value / 2 ...

Django/App Engine/Python 2.5: default __new__ takes no parameters

New to app engine and django. I think this is an issue with my django install, which is 1.1.1, but I've also read that I can just use the django packaged with the app engine SDK. Any help on why I'm getting this error when I test locally would be greatly appreciated. The callback: Variable Value callback <class 'ourlat.main.views.Se...

Django Timed Events

Hey Everyone, I want to schedule events to happen for my users. Is there an efficient way to do this in Python/Django easily? I'd prefer not to poll a priority queue. Thanks! Edit: I want to clarify that this job is run per user, for potentially hundreds or thousands of users. ...

Rendering mathematical notation in Python / OpenGL ?

How can I render mathematical notations / expressions in Python with OpenGL? I'm actually using pyglet however it uses OpenGL. Such things as this: I can't store static images as I am generating the expressions as well. ...

Doxygen C++ comment string parser in python?

Does anybody know of a python module to parse a doxygen style C++ comment string? I mean a string like this (simple example): /** * A constructor. * A more elaborate description of the constructor. * @param param1 test1 * @param param2 test2 */ and I would like to extract the brief, the long description, the parameter...

C++ iostreams and python

Is it possible to interoperate with a C++ iostream and python? I'm using boost-python and want to wrap a function that has istream and ostream as arguments. ...

How to write back to a certain cell in google doc spreadsheet using python

So the problem is, i get some information from first column of the row (for example A2 ) from the spreadsheet, then i will do some checking with that information, after that i want to write back to the next column in the row the result, how do i do that? Is there a certain function to allow me to indicate the column behind, in front, abo...

How to embed a graphical interactive IronPython shell in an application?

I've tried the obvious path in my pet open source project RevitPythonShell (a plugin for the building modeling software Autodesk Revit Architecture 2010): code.interact() with the IronPython engine set up to use .NET streams for STDIN and STDOUT. These I then redirect to a TextBox control. It kinda works, but really is only an ugly hack....

Tab not working properly in Python

Hey! I have been using NotePAD++ for editing Python scripts. I recently downloaded the PyDEV IDE (for Eclipse). The problem is that when I wrote the scripts in NotePad++ I used "TAB" for indentation, and now when I open them with PyDEV, every time I try to write a new line instead of "TABS" PyDEV inserts spaces. (even if I click the "TA...

Why does nose finds tests in files with only 644 permission?

Today I ran a bunch of doctests using Python 2.6 on a Ubuntu 9.10 with nose : nosetests --with-doctest Ran 0 tests in 0.001s OK WTF? I had tests in that files, why didn't that work? I changed permission to 644: sudo chmod 644 * -R nosetests --with-doctest Ran 11 test in 0.004s FAILED (errors=1) Changing it back to 777: sudo chm...

Need help on python sqlite?

1.I have a list of data and a sqlite DB filled with past data along with some stats on each data. I have to do the following operations with them. Check if each item in the list is present in DB. if no then collect some stats on the new item and add them to DB. Check if each item in DB is in the list. if no delete it from DB. I canno...