python

about one to many relationship in datastore and dereferncing in google app engine?

i have a one to many relationship between two entities the first one is a satellite and the second one is channel and the satellite form returns a satellite name which i want to appear in another html page with the channel data where you can say that this channel is related to that satellite how to make this ...

MS Outlook CDO/MAPI Blocking Python File Output?

Here is an example of the problem I am running into. I am using the Python Win32 extensions to access an Outlook mailbox and retrieve messages. Below is a script that should write "hello world" to a text file. I need to grab some messages from an Outlook mailbox and I noticed something weird. After I attach to the mailbox once, I can...

calculate exponential moving average in python

I have a range of dates and a measurement on each of those dates. I'd like to calculate an exponential moving average for each of the dates. Does anybody know how to do this? I'm new to python. It doesn't appear that averages are built into the standard python library, which strikes me as a little odd. Maybe I'm not looking in the r...

Validating Python Arguments in Subclasses

I'm trying to validate a few python arguments. Until we get the new static typing in Python 3.0, what is the best way of going about this. Here is an example of what I am attempting: class A(object): @accepts(int, int, int) def __init__(a, b, c): pass class B(A): @accepts(int, int, int, int) def __init__(a, b, ...

Given an rpm package name, query the yum database for updates

I was imagining a 3-line Python script to do this but the yum Python API is impenetrable. Is this even possible? Is writing a wrapper for 'yum list package-name' the only way to do this? ...

python super() raises TypeError ! Why ?

The following code raises a TypeError : >>> class X: ... def a(self): ... print "a" ... >>> class Y(X): ... def a(self): ... super(Y,self).a() ... print "b" ... >>> c = Y() >>> c.a() Traceback (most recent call last): File "", line 1, in File "", line 3, in a TypeError: super() argument 1 must be type, not classobj...

Why am I getting the following error in Python "ImportError: No module named py"?

I'm a Python newbie, so bear with me :) I created a file called test.py with the contents as follows: test.py import sys print sys.platform print 2 ** 100 I then ran import test.py file in the interpreter to follow an example in my book. When I do this, I get the output with the import error on the end. win32 12676506002282294014967...

Is there a way to make a user-defined Python function act like a built-in statement?

Is it possible to make a user-defined Python function act like a statement? In other words, I'd like to be able to say: myfunc rather than: myfunc() and have it get called anyway -- the way that, say, print would. I can already hear you all composing responses about how this is a horrible thing to do and I'm stupid for asking it a...

What are some common uses for Python decorators?

While I like to think of myself as a reasonably competent Python coder, one aspect of the language I've never been able to grok is decorators. I know what they are (superficially), I've read tutorials, examples, questions on Stack Overflow, and I understand the syntax, can write my own, occasionally use @classmethod and @staticmethod, b...

Connecting to MySQL with Python 2.6...how?

All my searches, including this question on Stack, point me to MySQLdb. Unfortunately MySQLdb doesn't have a version for Python 2.6. What am I to do? ...

Locking a file in Python

Hello, I need to lock a file for writing in Python. It will be accessed from multiple Python processes at once. I have found some solutions online, but most fail for my purposes as they are often only Unix based or Windows based. Any help would be appreciated. Thanks. ...

How can I extract x, y and z coordinates from geographical data by Python?

I have geographical data which has 14 variables. The data is in the following format: QUADNAME: rockport_colony_SD RESOLUTION: 10 ULLAT: 43.625 ULLON: -97.87527466 LRLAT: 43.5 LRLON: -97.75027466 HDATUM: 27 ZMIN: 361.58401489 ZMAX: 413.38400269 ZMEAN: 396.1293335 ZSIGMA: 12.36359215 PME...

Python: Convert list of ints to one number?

I have a list of integers that I would like to convert to one number like: numList = [1,2,3] num = magic(numList) print num, type(num) >>> 123, <type 'int'> What is the best way to implement the magic function? Thanks for your help. EDIT I did find this, but it seems like there has to be a better way. EDIT 2 Let's give some cred...

QScintilla scrollbar

When I add a QsciScintilla object to my main window the horizontal scrollbar is active and super wide (tons of apparent white space). Easy fix? ...

split a multi-page pdf file into multiple pdf files with python?

I'd like to take a multi-page pdf file and create separate pdf files per page. I've downloaded reportlab and have browsed the documentation, but it seems aimed at pdf generation, I haven't yet seen anything about processing pdf's themselves. Is there an easy way to do this in python? ...

Python Web Framework - Not App Framework or CMS Framework

I'm just getting into python on the web. I have a simple linux (CentOS) server with python installed into apache via mod_python. It all works great, but I don't really understand what to do about the Handler. It works, but I have to do low-level things like, at minimum, set the proper content_type of the request before I write out anythi...

What is the most pythonic way to make a bound method act like a function?

I'm using a Python API that expects me to pass it a function. However, for various reasons, I want to pass it a method, because I want the function to behave different depending on the instance it belongs to. If I pass it a method, the API will not call it with the correct 'self' argument, so I'm wondering how to turn a method into a fu...

django-cart or Satchmo?

I'm looking to implement a very basic shopping cart. Satchmo seems to install a lot of applications and extra stuff that I don't need. I've heard others mention django-cart. Has anyone tried this Django app (django-cart)? Anything to watch for or any other experiences? ...

Regex replace (in Python) - a more simple way?

Any time I want to replace a piece of text that is part of a larger piece of text, I always have to do something like: "(?P<start>some_pattern)(?P<replace>foo)(?P<end>end)" And then concatenate the start group with the new data for replace and then the end group. Is there a better method for this? ...

Statistics & other add-on tools for Planet blog aggregator software

Hi, The Planet software is often used for particular topics or large projects, to collect blogs that post on a particular theme. http://www.planetplanet.org/ I think there are lots of interesting add-ons that could be done for it but so far I haven't seen any. Does anyone know any? (Because of the name, it's kinda hard to search for......