I have a list of data that I want to search through. This new list of data is structured like so.
name, address dob family members age height etc..
I want to search through the lines of data so that I stop the search at the ',' that appears after the name to optimize the search. I believe I want to use this command:
str.find(sub[, sta...
I have a program that uses OpenGL combined with Cocoa and Python using PyObjC.
I've recently expanded on my menu making code to show menu selections for maps including map information. When using the new code, the window server will spontaneously crash at some random point (Not random but it appears that way). The new code uses nothing ...
I often do sorts in Python using lambda expressions, and although it works fine, I find it not very readable, and was hoping there might be a better way. Here is a typical use case for me.
I have a list of numbers, e.g., x = [12, 101, 4, 56, ...]
I have a separate list of indices: y = range(len(x))
I want to sort y based on the value...
I need to compile a binary file in pieces with pieces arriving in random order (yes, its a P2P project)
def write(filename, offset, data)
file.open(filename, "ab")
file.seek(offset)
file.write(data)
file.close()
Say I have a 32KB write(f, o, d) at offset 1MB into file and then another 32KB write(f, o, d) at offset ...
i am opening a csv file:
def get_file(start_file): #opens original file, reads it to array
with open(start_file,'rb') as f:
data=list(csv.reader(f))
header=data[0]
counter=collections.defaultdict(int)
for row in data:
counter[row[10]]+=1
return (data,counter,header)
does the file stay in memory if i quit the ...
What is SFINAE in C++? Can you please explain it in words understandable to a Python programmer? Also, what concept in Python does SFINAE in C++ correspond to?
...
I'm not sure why this Pickle example is not showing both of the dictionary definitions. As I understand it, "ab+" should mean that the pickle.dat file is being appended to and can be read from. I'm new to the whole pickle concept, but the tutorials on the net don't seem to go beyond just the initial storage.
import cPickle as pickle
de...
I am having a problem using mencoder (SVN-r30531-4.2.1) through a python (2.6.1) subprocess. I am trying to join two mp4 files which are exactly the same size, codec, etc. Both have no audio. The code I am using to test is:
import subprocess
mp4merge = [ "mencoder", "in1.mp4", "in2.mp4", "-ovc", "copy", "-oac", "copy", "-of", "lavf", "...
I've written a remote Python debugger and one of the features I need is to execute arbitrary code while stopped at a breakpoint. My debugger uses the following to execute code received from the remote debugger:
exec (compile(code, '<string>', 'single') , frame.f_globals, frame.f_locals)
This works fine for the most part, but I've noti...
I have a .ics file in the following format. What is the best way to parse it. I need to retrieve the Summary, Description, and Time for each of the entries. Thanks in advance for your help.
BEGIN:VCALENDAR
X-LOTUS-CHARSET:UTF-8
VERSION:2.0
PRODID:-//Lotus Development Corporation//NONSGML Notes 8.0//EN
METHOD:PUBLISH
BEGIN:VTIMEZONE
TZI...
I'm using Pylons/Genshi, and trying to show 'all recent comments' on my site with a Disqus javascript widget (Disqus is installed on the site, and I can post comments OK).
However, the code below produces a nasty 500 error:
TemplateSyntaxError: not well-formed (invalid token): line 25, column 121 (line 25 is the <script> line).
<d...
Hello, I would like to use the dbm module on my Windows machine, but it is currently only supported on Unix. http://docs.python.org/library/dbm.html
Does anyone know of a similar module with similar syntax or a workaround to get dmb functional on windows? Being able to access a database written to the hard drive much like how I code to ...
Hi guys, i am using the Python lib to access Gmail and Contacts. Is it possible to bypass the screen that allows the user to select among multiple google accounts. I already know the account he wants to import so I ld like to display the Grant Access screen after the redirection as some other apps do.
The code i use now is:
google = gd...
Hey all,
I need to convert a string to a datetime object, along with the fractional seconds. I'm running into various problems.
Normally, i would do:
>>> datetime.datetime.strptime(val, "%Y-%m-%dT%H:%M:%S.%f")
But errors and old docs showed me that python2.5's strptime does not have %f...
Investigating further, it seems that the Ap...
Hello, I have a Dictionary of Classes where the classes hold attributes that are lists of strings.
I made this function to find out the max number of items are in one of those lists for a particular person.
def find_max_var_amt(some_person) #pass in a patient id number, get back their max number of variables for a type of variable
...
So I need to be able to open several images in a grid layout and click on the images to perform various actions. Right now I am adding the images to a grid sizer. How do I capture mouse events from a sizer? Or should I display the images in another way to make it easy to respond to mouse events?
...
i am building a URL and replacing all the spaces with +
url.replace(' ','+')
for some reason it is not replacing any of the white spaces!
anyone know what is wrong?
...
Hi,
I am working to create a version of asteroids using Python and Tkinter. When the left or right arrow key is pressed the ship needs to rotate. The ship is a triangle on the Tkinter canvas. I am having trouble coming up with formula to adjust the coordinates for the triangle. I believe it has something to do with sin and cos, though I...
I need to test an issue that occurs on Windows with Python 2.5, but the releases page doesn't link to a binary for 2.5.
Is there anywhere I could find a copy?
...
So here is my program with some new modifications:
datafile = open('C:\\text2.txt', 'r')
completedataset = open('C:\\bigfile.txt', 'r')
smallerdataset = open('C:\\smallerdataset.txt', 'w')
matchedLines = []
for line in datafile:
splitline = line.split()
for item in splitline:
if not item.endswith("NOVA"):
if ...