python

Calling a function with variable number of arguments with an array in C++ (like python's * operator)

Hello world! I'm trying to write a v8 module in C++; there, the functions receive a variable number of arguments in an array. I want to take that array and call a function like gettext and printf that receives a formatted string and it's necessary args. The thing is, how can one take an array and send the elements as arguments to one of...

[Errno 10061] Python smtp connection is always failed in a VMware Windows machine

Hi, I m trying to use smtp class from Python 2.6.4 to send smtp email from a WinXP VMware machine. After the send method is called, I always got this error: socket.error: [Errno 10061] No connection could be made because the target machine actively refused it. Few stuff I noticed: The same code works in the physical WinXP machine w...

Optional dependencies in a pip requirements file

How can I specify optional dependencies in a pip requirements file? According to the pip documentation this is possible, but the documentation doesn't explain how to do it and I can't find any examples on the web. ...

Django Permissions and Security for Basic Chat App

If I wanted to implement some sort of chat tool in my django webapp, implemented with basic ajax polling as opposed to comet, what should I do to secure it, besides running over SSL. Should I just use the permissions app for each chat session and generate a random token to be accessed in my urlconf? Are there better/different approaches ...

What kind of python process to monitor a queueing system like kestrel or rabbitmq?

I'm fairly new to python, and I was wondering what kind of application would you create to constanstly monitor a queueing service like kestrel or rabbitmq? How would it run, and under what context? Would it be a simple python script that would have a infinit while loop? I'm looking for a long running, stable python service that would ...

Sqlalchemy seems to commit changes when it's not supposed to

Consider the following snippet of Python code: from sqlalchemy import * from sqlalchemy.orm import * db = create_engine('postgresql:///database', isolation_level='SERIALIZABLE') Session = scoped_session(sessionmaker(bind=db, autocommit=False)) s = Session() s.add(SomeInstance()) s.flush() raw_input('Did it work? ') It connects to the ...

When using paster web server, does it service requests by creating a new thread?

Does paster create a new thread per request? Can you set the maximum number of threads for paster to use i.e. a thread pool? How can you if this is possible? ...

AppEngine Python - updating entity properties without twenty elif statements

Suppose I have an AppEngine model defined with twenty different StringProperty properties. And then I have a web form, which POSTs updated values for an entity of this model. I end up with something like this after reading in the form data: entity_key['name'] = 'new_name' entity_key['city'] = 'new_city' entity_key['state'] = 'new_stat...

What is the use of FieldStorage in Python

I want to know whats the difference between FieldStorage in Python and wsgi_input? ...

Django profiling module error

Hi all, I have an error from the following code. I am sure it is obviuous to someone with more Python experience. This is a snippet from http://djangosnippets.org/snippets/727/ import sys import cProfile from cStringIO import StringIO from django.conf import settings class ProfilerMiddleware(object): def process_view(self, request,...

web.py on Google App Engine

I'm trying to get a web.py application running on GAE. I hoped that sth like the following might work import web from google.appengine.ext.webapp.util import run_wsgi_app [...] def main(): app = web.application(urls, globals()) run_wsgi_app(app) But obviously the app object doesn't conform with the run_wsgi_app function's ex...

How to uniqufy the tuple element?

i have a result tuple of dictionaries. result = ({'name': 'xxx', 'score': 120L }, {'name': 'xxx', 'score': 100L}, {'name': 'yyy', 'score': 10L}) I want to uniqify it. After uniqify operation result = ({'name': 'xxx', 'score': 120L }, {'name': 'yyy', 'score': 10L}) The result contain only one dictionary of each name and the dict shoul...

how to connect HAL using dbus

I'm using python and dbus. What i really need is a way to get the input from my microphone into my python program and then play it back from the program. I googled a lot and it seems pyaudio might do the trick but pyaudio does not work with my ubuntu 10.04. The next option i saw was telepathy. But i don't need something that big, eithe...

Python 3 I think I have a type mismatch but can't find it

Hi, I'm using Python 3.1 to write a simple game involving naming state capitols. I think I have some kind of type mismatch but I don't know what it is. I think it's when I compare the player's answer to the real answer, but don't know how to make it right. from random import * states = {} print ("Guess State Capitols") statefile = o...

Python - Open source projects suggestions

Possible Duplicate: What are good open source projects in Python for which I can be a contributor? I have been working on Python for sometime now. I just thought I could improve my skills my coding in open source projects. But I'm new to open source! Some suggestions on how I go about doing this and projects for beginners like...

How is Ruby more object-oriented than Python?

Matz, who invented Ruby, said that he designed the language to be more object-oriented than Python. How is Ruby more object-oriented than Python? ...

Are order of keys() and values() in python dictionary guaranteed to be the same?

Does native built-in python dict guarantee that the keys() and values() lists are ordered in the same way? d = {'A':1, 'B':2, 'C':3, 'D':4 } # or any other content otherd = dict(zip(d.keys(), d.values())) Do I always have d == otherd ? Either it's true or false, I'm interested in any reference pointer on the subject. PS: I understan...

How to check constraints between elements in a list / is this Constraint Programming?

I have many variable-sized lists containing instances of the same class with attribute foo, and for every list I must apply rules like: if there's an element foo=A there cannot be elements with foo in [B,C,D] if there's an element foo=X there must by at least one with foo in [Y,Z] there can be between MIN and MAX elements foo=BAR com...

Can I get SQLite to string instead of unicode for TEXT in Python?

AFAIK SQLite returns unicode objects for TEXT in Python. Is it possible to get SQLite to return string objects instead? ...

Alternative to python atexit module that works when called from other scripts

Using atexit.register(function) to register a function to be called when your python script exits is a common practice. The problem is that I identified a case when this fails in an ugly way: if your script it executed from another python script using the execfile(). In this case you will discover that Python will not be able to locate...