Hi I have a file that consists of too many columns to open in excel. Each column has 10 rows of numerical values 0-2 and has a row saying the title of the column. I would like the output to be the name of the column and the average value of the 10 rows. The file is too large to open in excel 2000 so I have to try using python. Any tips o...
I'm trying to build a Python application using pyGTK, treads, and sockets. I'm having this weird error, but given all the modules involved, I'm not entirely sure where the error is. I did a little debugging with some print statements to narrow things down a bit and I think the error is somewhere in this snippet of code:
self.sock = ...
I have a tiled spritesheet saved as a png image that I want to load as a pyglet.image.Animation. I can see how to load an animation from a gif or a series of images, but I can't even figure out how to preform image slicing on images.
...
For some reason duplicate values aren't eliminated.
records = Records.objects.all()
records2 = records.values_list('columna','columna').distinct()
print records2
I must be doing something stupid
...
When I post a JSON string to Django by Ajax, it converts it into an invalid JSON format. Specifically, if I look in the post data in Firebug I am sending:
info {'mid':1,'sid':27,'name':'aa','desc':'Enter info' }
Yet when I access it in the django request I am seeing:
u'{\'mid\':1,\'sid\':27,\'name\':\'aa\',\'desc\':\'Enter Info\'}...
I'm working on a python script that monitors a directory and uploads files that have been created or modified using scp. That's fine, except I want this to be done recursively, and I'm having a problem if a user creates a directory in the watch directory, and then modifies a file inside that new directory.
I can detect the directory cre...
I read the ini file to open a file in python.
The thing is that the file info is sometimes inside the "..", but sometimes it's not.
For example,
fileA = "/a/b/c.txt"
fileB = /a/b/d.txt
Is there easy way to detect if a string is wrapped in "..", and return the string inside the quotation?
...
Hi , I am new to this and am just trying to understand the with statement.I get to understand that it is supposed to replace the try except block.Now suppose I do something like this:-
try:
name='rubicon'/2 #to raise an exception
except Exception,e:
print "no not possible"
finally:
print"Ok I caught you"
Now how do I replace ...
I am trying to install a python blue tooth library on my jail broken iPod touch but get errors on the install
trying to install lightblue i get an error to do with finding the correct complier, i have installed gcc but cannot find any ports of xcodebuild
http://pastebin.com/fdgzYjhr
and trying to install light blue there seems to be a...
Hi
I need script which starts itself at the end of process.
I use this code but it wait for execfile. How to run it async? To do the effect of script restarting.
import time
print "start"
time.sleep(5)
print "go exec"
execfile('res.py')
print "stop exec"
...
def index_dir(self, base_path):
num_files_indexed = 0
allfiles = os.listdir(base_path)
#print allfiles
num_files_indexed = len(allfiles)
#print num_files_indexed
docnumber = 0
self._inverted_index = {} #dictionary
for file in allfiles:
self.documents = ...
I'm working on a python script that stores ssh passwords only during the current session. What I'm doing is declaring a class variable credentials = {}. When the script needs access to a specific server, it checks in credentials to see if credentials['server'] exists. If it does, it uses the password there, if it doesn't, it prompts the ...
I know how python dictionaries store key: value tuples. In the project I'm working on, I'm required to store key associated with a value that's a list.
ex:
key -> [0,2,4,5,8]
where,
key is a word from text file
the list value contains ints that stand for the DocIDs in which the word occurs.
as soon as I find the same word in another d...
I want to remove a incorrectly installed program and reinstall it. I can remove the program with subprocess.Popen calling the msiexe on it and install new program the same way BUT ONLY with two independent scripts. But i also need to remove some folders in C:\Programs files and also in C:\Doc& Settings. How can i traverse through the dir...
Pretty simple, in my AppEngine application, I have over 1 million entities of one kind, what is the best way to pick one at random?
...
How can i use python to read .cbr/.cbt files?
...
Ive been roaming around the interwebs looking for my first open-source project to contribute to - and most cool ones seem to be one-man bands on github, which I could fork - but wouldnt quite provide the code review etc. i think i want, so i can improve my python abilities.
Web.py, flask, celery, twisted etc look interesting - so far on...
I am looking for an appropriate data structure in Python for processing variably structured forms. By variably structured forms I mean that the number of form fields and the types of the form's contents are not known in advance. They are defined by the user who populates the forms with his input.
What are the pros and cons of putting da...
In Python, consider I have the following code:
>>> class SuperClass(object):
def __init__(self, x):
self.x = x
>>> class SubClass(SuperClass):
def __init__(self, y):
self.y = y
# how do I initialize the SuperClass __init__ here?
How do I initialize the SuperClass __init__ in the subclass? I am followi...
This is mostly just because I'm curious, but how would one distribute a closed source python program since python is run from source and its bytecode is easily decompiled? I'm mostly asking for linux since I don't care about windows, but any answers are great.
Edit:
Thanks for the answers guys. I was just curious since I just got my fi...