In my example code below, is the counter = 0 really required, or is there a better, more Python, way to get access to a loop counter? I saw a few PEPs related to loop counters, but they were either deferred or rejected (PEP 212 and PEP 281).
This is a simplified example of my problem. In my real application this is done with graphics an...
I need some properties to be unique. How can I achieve this?
Is there something like unique=True?
I'm using Google App Engine for Python.
...
How would you create an algorithm to solve the following puzzle, "Mastermind"?
Your opponent has chosen four different colours from a set of six (yellow, blue, green, red, orange, purple). You must guess which they have chosen, and in what order. After each guess, your opponent tells you how many (but not which) of the colours you guess...
Hello!
Consider:
pipe_read, pipe_write = os.pipe()
Now, I would like to know two things:
(1) I have two threads. If I guarantee that only one is reading os.read(pipe_read,n) and the other is only writing os.write(pipe_write), will I have any problem, even if the two threads do it simultaneously? Will I get all data that was written ...
I'm trying to slowly knock out all of the intricacies of python. Basically, I'm looking for some way, in python, to take a string of characters and push them all over by 'x' characters.
For example, inputing abcdefg will give me cdefghi (if x is 2).
Thanks!
...
Does anyone know how to associate the py extension with the python interpreter on Mac OS X 10.5.7? I have gotten as far as selecting the application with which to associate it (/System/Library/Frameworks/Python.framework/Versions/2.5/bin/python), but the python executable appears as a non-selectable grayed-out item. Any ideas?
Thanks,
-...
Hi,
I wonder what is the best way to handle parallel SSH connections in python.
I need to open several SSH connections to keep in background and to feed commands in interactive or timed batch way.
Is this possible to do it with the paramiko libraries? It would be nice not to spawn a different SSH process for each connection.
Thanks.
...
I'm trying to make a web app that will manage my Mercurial repositories for me.
I want it so that when I tell it to load repository X:
Connect to a MySQL server and make sure X exists.
Check if the user is allowed to access the repository.
If above is true, get the location of X from a mysql server.
Run a hgweb cgi script (python) cont...
The Python manual says that you can create modules for Python in both C and C++. Can you take advantage of things like classes and templates when using C++? Wouldn't it create incompatibilities with the rest of the libraries and with the interpreter?
...
I'm looking for a way to read specific files from a rar archive into memory. Specifically they are a collection of numbered image files (I'm writing a comic reader). While I can simply unrar these files and load them as needed (deleting them when done), I'd prefer to avoid that if possible.
That all said, I'd prefer a solution that's ...
I want to learn it but I have NO idea where to start. Everything out there suggests reading the libpurple source but I don't think i understand enough c to really get a grasp of it.
...
How should new nodes be added with SQLAlchemy to a tree implemented using the Nested Set Model?
class Category(Base):
__tablename__ = 'categories'
id = Column(Integer, primary_key=True)
name = Column(String(128), nullable=False)
lft = Column(Integer, nullable=False, unique=True)
rgt = Column(Integer, nullable=False,...
I realize this is a dated question since appengine now comes in java, but I have a python appengine app that I want to access via GWT. Python is just better for server-side text processing (using pyparsing of course!). I have tried to interpret GWT's client-side RPC and that is convoluted since there is no python counterpart (python-gw...
This question is in relation to another question asked here:
Sorting 1M records
I have since figured out the problem I was having with sorting. I was sorting items from a dictionary into a list every time I updated the data. I have since realized that a lot of the power of Python's sort resides in the fact that it sorts data more quic...
I'd like to use the following form class in a modelformset. It takes a maps parameter and customizes the form fields accordingly.
class MyModelForm(forms.ModelForm):
def __init__(self, maps, *args, **kwargs):
super(MyModelForm, self).__init__(*args, **kwargs)
#customize fields here
class Meta:
model = My...
I have a script named test1.py which is not in a module. It just has code that should execute when the script itself is run. There are no functions, classes, methods etc. I have another script which runs as a service. I want to call test1.py from the script running as a service.
eg:
test1.py
print "I am a test"
print "see! I do nothin...
Hello,
The background is that I've got a celery distributed job server configured with a Django view that returns the status of a running job in JSON. The job server is located at celeryserver.mydomain.com and the page I'm executing the jQuery from is www.mydomain.com so I shouldn't need to consider JSONP for this should I, as the req...
I've only used XML RPC and I haven't really delved into SOAP but I'm trying to find a good comprehensive guide, with real world examples or even a walkthrough of some minimal REST application.
I'm most comfortable with Python/PHP.
...
If I import a module in IDLE using:
import <module_name>
print <module_name>.__file__
how can I open it without going through the Menu->File->Open multiple-step procedure?
It would be nice to open it via a command that takes the path and outputs a separate editor like IDLE.
...
This my code
service part
class Test:
def hello():
return "Hello World"
server Part
import SOAPpy
from first_SOAP import *
host = "127.0.0.1"
port = 5551
SOAPpy.Config.debug = 1
server = SOAPpy.SOAPServer((host, port))
server.registerKWFunction(Test.hello)
print "Server Runing"
server.serve_forever(
Client part
...