python

Subsetting data in python

Hi, I want to use the equivalent of the subset command in R for some python code I am writing. Here is my data: col1 col2 col3 col4 col5 100002 2006 1.1 0.01 6352 100002 2006 1.2 0.84 304518 100002 2006 2 1.52 148219 100002 2007 1.1 0.01 6292 10002 2006 1.1 0.01 5968 10002 2006 1....

Is the Python standard library really standard?

Is the Python standard library standard in the sense that if Python is installed, then the standard library is installed too? The documentation reads For Unix-like operating systems Python is normally provided as a collection of packages, so it may be necessary to use the packaging tools provided with the operating system to obtain ...

[PyAMF] How to use the remote object properly in flex, with as3 and pyamf or phpamf server side

I see that I never get a response from server when making a request. im using firebug to test the network communications. ...

raw_input in python

when using raw_input in a loop, until a certain character is typed (say 'a') how can I print all the inputs before that, in reverse order, without storing the inputs in a data structure? using a string is simple: def foo(): x = raw_input("Enter character: ") string = "" while not (str(x) == "a"): string = str(x) + ...

Django TemplateSyntaxError

I am getting a TemplateSyntaxError, that is only happening on my dev server, but works fine on the django testing server locally. Here's the error Caught SyntaxError while rendering: invalid syntax (urls.py, line 1) and the html: <li><a href="{% url plan.views.profile %}">Plan Details</a></li> and here is the profile view: @login...

Appropriate Data structure

I have to implement the value iteration algorithm for finding the optimal policy for each state of an MDP using Bellman's equation. The input file is some thing like below: s1 0 (a1 s1 0.5) (a1 s2 0.5) (a2 s1 1.0) s2 0 (a1 s2 1.0) (a2 s1 0.5) (a2 s3 0.5) s3 10 (a1 s2 1.0) (a2 s3 0.5) (a2 s4 0.5) where s1 is the state 0 is the reward ass...

How to construct GQL to not contain a value from a set?

Is it possible to select from a google app engine db where the key of a db.Model object is not in a given list? If so, what would be the syntax? Ex of a model class: class Spam(db.Model): field1 = db.BooleanProperty(default=false) field2 = db.IntegerProperty() Example of a query which I'd like to work but can't figure out: ...

twisted: unhelpful "AlreadyCalled" error

My twisted python program keeps spewing this message ever so often: Unhandled error in Deferred: Traceback (most recent call last): File "c:\python25\lib\site-packages\twisted\internet\defer.py", line 757, in gotResult _inlineCallbacks(r, g, deferred) File "c:\python25\lib\site-packages\twisted\internet\defer.py", line 747, in ...

How to change the message in a Python AssertionError?

I'm writing per the following, in which I try to produce a decent error message when comparing two multiline blocks of Unicode text. The interior method that does the comparison raises an assertion, but the default explanation is useless to me I need to add something to code such as this below: def assert_long_strings_equal(one, other)...

403 error when trying to run CherryPy behind Apache

I am trying to run CherryPy behind Apache using mod_rewrite, as described in the CherryPy documentation (BehindApache, ModRewrite), and it is not working. Edit: Earlier, my description of this problem was somewhat inaccurate. It seems like I forgot to restart Apache during some of my attempts. I have revised the question significantly. ...

Passing Arguments with Newstyle signals in PyQT

I've been having some trouble with a set of dynamically created buttons in PyQT. I'm using a list to create buttons corresponding to different values. Because each button is different, I need to have them pass an argument to the "Button Clicked" function identifying themselves separately so I can perform different actions with them. He...

Set timeout on getaddrinfo() in Python

Is it possible to set a timeout on a getaddrinfo() call in CPython 2.7? socket.setdefaulttimeout() does not work. I don't really want a solution that wraps a function using threads or signals. A solution that only uses the standard library is best, but using a third-party package would be acceptable. For example, I want to do this: ...

Pass success_url to the activate

Docs say : ``success_url`` The name of a URL pattern to redirect to on successful acivation. This is optional; if not specified, this will be obtained by calling the backend's ``post_activation_redirect()`` method. How can I do it ? ...

qooxdoo and debian lenny

Hy, Trying to use qooxdoo with debian lenny. qooxdoo sdk 1.2 create-application.py ok but I've got a problem with generate.py : /demo/qooxdoo/hello1$ ./generate.py source-all Traceback (most recent call last): File "/demo/qooxdoo-1.2-sdk/tool/bin/generator.py", line 26, in <module> from generator.Generator import Generator Fil...

Creating a website to communicate with an embedded device

I'm currently working on a project where I'm trying to control an embedded device through an Internet facing website. The idea is is that a user can go to a website and tell this device to preform some kind of action. An action on the website would be translated into a series of CLI commands and then sent to the device. Communication cou...

Elixir - deleting rows in a ManyToMany intermediate table

Hi, I have two tables with a ManyToMany relation between them. Sometimes I need to refresh the database so I delete elements from both tables. However relations between deleted rows are still stored inside the automatically created intermediary table. To clarify the problem, here is a small code: from elixir import * metadata.bind =...

Error when the Email formencode validator

Hello, I wanted to create an IDN-aware formencode validator to use in one of my projects. I used a portion of code from the Django project (http://code.djangoproject.com/svn/django/trunk/django/core/validators.py) to do that, but there must be a trivial error in my code I can't find : class Email(formencode.validators.Email): def _...

Mac Ports Python 2.6.6 and Tkinter

Hi guys, I apologize if this has been asked but does Tkinter work in Python 2.6.6 when installed with Mac Ports? Or do I need to pass the no_tkinter variant? Thanks for any help! ...

Print info about exception in python 2.5?

Python 2.5 won't let me use this syntax: try: code_that_raises_exception() except Exception as e: print e raise So how should I print information about an exception? Thanks EDIT: I'm writing a plugin for a program that includes kind of a pseudo python interpreter. It prints print statements but doesn't show exceptions at ...

decorator inside class & decorated classmethod without 'self' gives strange results

Example code: # -*- coding: utf-8 -*- from functools import wraps class MyClass(object): def __init__(self): pass #decorator inside class def call(f): @wraps(f) def wrapper(*args): print 'Wrapper: ', args return wrapper #decorated 'method' without self @call def myfunc(a): pass c = MyClass() c....