In some of my code I put a series of objects in a list and I build an additional list out of their attributes, which is a string. I need to determine if all the items in this second list have the exact same value, without knowing beforehand which value it is, and return a bool so that I can do different things in my code depending on th...
Hi,
I have come to appreciate a lot boost::multi_index in C++. It happens that I would happily use something like that in Python; for scripts that process data coming out from numerical intensive applications. Is there such a thing for Python? I just want to be sure that it doesn't exist, then I would try to implement it myself. Things ...
I'm running this my simple code:
import threading, time
class reqthread ( threading.Thread ):
def __init__ (self):
threading.Thread.__init__(self)
def run ( self ):
for i in range(0,10):
time.sleep(1)
print '.'
try:
thread=reqthread()
thread.start()
except (KeyboardInterrupt, SystemExit):
print '\n! Rece...
Hi here is my problem. I have a program that calulcates the averages of data in columns.
Example
Bob
1
2
3
the output is
Bob
2
Some of the data has 'na's
So for Joe
Joe
NA
NA
NA
I want this output to be NA
so I wrote an if else loop
The problem is that it doesn't execute the second part of the loop and just prints out one NA. ...
Emacs's auto-fill mode splits the line to make the document look nice. I need to join the strings read from the document.
For example, (CR is the carriage return, not the real character)
- Blah, Blah, and (CR)
Blah, Blah, Blah, (CR)
Blah, Blah (CR)
- A, B, C (CR)
Blah, Blah, Blah, (CR)
Blah, Blah (CR)
is read ...
I have a simple file transfer socket program where one socket sends file data and another socket receives the data and writes to a file
I need to send an acknowledgment once transfer is finished from the destination to the source
Code for destination
s.accept()
f = s.makefile()
f.read(1024)
Code for source
s.connect(('localhost',609...
I am working on a client for a web service using pycurl. The client opens a connection to a stream service and spawns it into a separate thread. Here's a stripped down version of how the connection is set up:
def _setup_connection(self):
self.conn = pycurl.Curl()
self.conn.setopt(pycurl.URL, FILTER_URL)
self.conn.setopt(py...
Hi all,
I am considering a 3rd part Authentication system for logging in (new/old) users. Much like how StackOverflow authenticates it's users. This scheme is good as it frees me from doing authentication from my side. I need this -
Login using Google, Facebook, Twitter, Yahoo, OpenID Authentication Systems.
Provide the same user logge...
I want to check in a Python program if a word is in the English dictionary.
I believe nltk wordnet interface might be the way to go but I have no clue how to use it for such a simple task.
def is_english_word(word):
pass # how to I implement is_english_word?
is_english_word(token.lower())
In the future, I might want to check if ...
I'm running into an issue while unit-testing a Python project that I'm working on which uses generators. Simplified, the project/unit-test looks like this:
I have a setUp() function which creates a Person instance. Person is a class that has a generator, next_task(), which yields the next task that a Person has.
I now have two unit-tes...
I'm using Python's BaseHTTPRequestHandler. When I implement the do_GET method I find myself parsing by hand self.path
self.path looks something like:
/?parameter=value&other=some
How should I parse it in order to get a dict like
{'parameter': 'value', 'other':'some'}
Thanks,
...
I have written a program that communicates with many servers at once using the asyncore module. For the most part I am just responding to data received from the servers, but occasionally I need to send some data "out-of-sync". With the default timeout of 30 seconds there is an obvious delay before the packet gets sent, so I have lowered ...
Hi all
I have a ctypes structure.
class S1 (ctypes.Structure):
_fields_ = [
('A', ctypes.c_uint16 * 10),
('B', ctypes.c_uint32),
('C', ctypes.c_uint32) ]
if I have X=S1(), I would like to return a dictionary out of this object: Example, if I do something like: Y = X.getdict() or Y = getdict(X), then Y ...
Hi,
I'm making a new website to replace a current one, using Flask micro-framework (based on Werkzeug) which uses Python (2.6 in my case).
The core functionality and many pages are the same. However by using Flask many of the previous URLs are different to the old ones.
I need a way to somehow store the each of the old URLs and the ne...
Is it possible to load a python function from a string and then call that function with arguments and get the return value?
I'm using the python C API to run python code from inside my C++ application. I'm able to load a module from a file using PyImport_Import, get a function object from that using PyObject_GetAttrString, and call the ...
Possible Duplicate:
Python, Unicode, and the Windows console
I have a folder with a filename "01 - ナナナン塊.txt"
I open python at the interactive prompt in the same folder as the file and attempt to walk the folder hierachy:
Python 3.1.2 (r312:79149, Mar 21 2010, 00:41:52) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copy...
Hello,
I'm making a simple web app where I have some simple python scripts that do the text crunchin g I need - but I'm not quite sure how to interface it with a client who'd only want to see some HTML forms.
There's so many different server side frameworks out there - but I don't think I need anything too heavy duty - just a mechanism...
There is a SQL Compact v3.1 database that I want to quickly read. I'm doing this in python so I don't have access to managed code.
I've noticed that if I use adodbapi the database file actually gets modified just by opening it. And sadly when I add 'File mode=Read Only' to the connection string I get a weird error.
Here is the code I...
Does Java have an equivalent to Python's range(int, int) method?
...
A module that I have written (test.py) in Python 2.6 can be imported and run perfectly well from with the Python IDLE with the commands:
import test
test.run_test_suite()
However if I use the command "python test.py" at the command line, it crashes apparently (according to traceback) on the command "import os".
As you can see from th...