How to define a function that takes a string (sentence) and inserts an extra space after a period if the period is directly followed by a letter.
sent = "This is a test.Start testing!"
def normal(sent):
list_of_words = sent.split()
...
This should print out
"This is a test. Start testing!"
I suppose I should use split()...
I need a memory-efficient data structure for for storing about a million key--value pairs, where keys are strings of about 80 bytes, and values are strings of about 200 bytes, the total key and value size being about 280MB. I also need efficient lookup of value by key, preferably a hash-map. The memory overhead should be as little as pos...
I have a SQL server 2005 server database on a server and need to conect to it from a client on the same server network, any ideas?
...
I'm trying to build a web app that grabs fantasy sports info from Yahoo's API. I know that it requires the use of OAuth in order to speak to the API. It's being created using Flask and will run on Google App Engine.
I've been trying to use python-oauth2 from the folks at SimpleGeo and I keep getting the same exact error when trying to...
I'm attempting to connect to a SQL Server database within a Python script. I'm using SQLNCLI as provider on my connection string.
from win32com.client import Dispatch
connection_string = "Provider=SQLNCLI;server=%s;initial catalog=%s;user id=%s;password=%s"%(server,db_name,user,pwd)
dbConn = Dispatch("ADODB.Connection")
dbConn.Open( ...
After Google pioneered map-reduce the community came out with Hadoop, is there a OSS Google AppEngine project? Or, put another way: What is the best off the shelf python or java cloud software?
Specifically I'm looking for something that I could host on my own and have some sort of auto-scale feature (more frequently used apps would be ...
I am attempting to debug a problem with a ctypes wrapper of a windows DLL and have noticed differences when I run tests via an interactive shell (python or ipython) and when I run the scripts non-interactively.
I was wondering if there is any explanation for the differences I am seeing here?
Specifically, when I interactively run a sim...
If I have the list:
lista=[99, True, "Una Lista", [1,3]]
What does the following expression mean?
mi_var = lista[0:4:2]
...
I'm experimenting with Python 2.7's new Tkinter Tile support (ttk). Is there a way to make the ttk.Progressbar() control auto-resize in proportion to its parent container? In reading the documentation on this control, it appears that one must explicitly set this widget's height or width?
I'm looking for a way to place the ttk.Progressba...
I am calling a python script that uses imaplib.py and get the "no module named fcntl" error. From searching I found that this module is only available in unix and so I wonder if the py script is confused about what os it is running under. Again, script works fine under windows run directly from the python directory.
var engine = P...
From the mighty PEP 8:
[P]lease limit all lines to a maximum of 79 characters. For flowing long blocks of text (docstrings or comments), limiting the length to 72 characters is recommended.
When editing Python code in Vim, I set my textwidth to 79, and Vim automatically wraps long lines of Python code for me when I hit the charact...
I couldn't find any documentation of the optional parameters that are available to all field types in OpenERP models, so I added what I knew to the fields documentation page. (Until the web site gets regenerated, you can see it in the documentation source.)
There are a bunch of parameters that I don't understand, so I'd appreciate help...
I have my directory structure like this:
root/
sift/
__init__.py
sift_descriptors.proto
sift_descriptors_pb2.py
project/
__init__.py
filtered_descriptors.proto
filtered_descriptors_pb2.py
filtered_descriptors_test.py
The root directory is in my $PYTHONPATH.
I build root/sift/sift_descriptors_pb2.py usi...
This is a situation I've run into several times, not sure what the best approach is.
Let's say I have some kind of dynamic content that users can add to via Ajax. For example, take Stack Overflow's comments - people can add comments directly on to the page using Ajax.
The question is, how do I implement the addition itself of the new c...
I wonder if it is bad manner to skip return None, when it is not needed.
Example:
def foo1(x):
if [some condition]:
return Baz(x)
else:
return None
def foo2(x):
if [some condition]:
return Baz(x)
bar1 = foo1(x)
bar2 = foo2(x)
In both cases, when condition is false, function will return with None....
I have a C/C++ application in which I define a Python module. I set up Python like this:
PyImport_AppendInittab("myModule", initmymodule);
Py_Initialize();
PyObject *module = PyImport_ImportModule("myModule");
On the ImportModule call, I get this warning:
sys:1: RuntimeWarning: Python C API version mismatch for module myModule: T...
A small piece of python code breaks/exits with -1073741819 within SciTE.
Is there a way to attach a system sound or anything to alert me on exit.
So far, its a silent break.
...
I'm writing a module to act on data being sent to a database from Python. Since boolean is not a SQL datatype, those values have to be converted to some pre-defined value. I decided while defining the tables that I would use 'T' and 'F' in a varchar(1) field as my Boolean stand in.
In attempting to make this conversion while being pro...
I've recently switched entirely to Vim for all my Python/Django development. It took me a lot of time to customize it to the point it is today, and God knows how hard it was for me to find help regarding the best vim plugins out there suited for Python/Django development.
I decided to ask this question so people like me could benefit di...
Feeling pretty brain-dead right now. I can, of course, brute-force this, but I feel like there has to be a simple function to return this number. Concerning native functions, I'm using PHP and/or Python.
For example: there exists containers that hold X (5) breadsticks each, and
I need to feed Y (25) people Z (3) breadsticks each.
I ...