I have been doing a bit of programming in Python (still a n00b at it) and came across something odd. I made a small program to find the MD5 hash of a filename passed to it on the command line. I used a function I found here on SO. When I ran it against a file, I got a hash "58a...113". But when I ran Microsoft's FCIV or the md5sum.py...
so, I read from DB binary field i.e. 'field1' to var Buf1, and then do something like:
unpack_from('I', Buf1, 0)
so, all is ok. but question is how can I ini Buf1 without going to DB? I can get value from DB manually and init my var statically, but how? in DB field 'field1' I see something like '0x7B0500000100000064000000B80100006'. ...
Hey guys/gals I'm writing a python script that fixes some duplicate issues on my database. I would like to display some progress status to the users, currently I just print it like this:
print "Merged " + str(idx) + " out of " + str(totalCount);
The problem is that it prints that in a new line for every record and that does not look s...
I'm researching how to best extend a C++ application with scripting capability, and I am looking at either Python or JavaScript. User-defined scripts will need the ability to access the application's data model.
Have any of you had experiences with embedding these scripting engines? What are some potential pitfalls?
...
I have two programs, recvfile.py and sendfile.cpp. They work except that I end up with a bunch of extra newline characters at the end of the new file. I don't know how the extra spaces get there. I know the problem is sender side, because the same doesn't happen when I use python's sendall() function to send the file.
Here are the files...
I'm learning about metaclasses in Python. I think it is a very powerful technique, and I'm looking for good uses for them. I'd like some feedback of good useful real-world examples of using metaclasses. I'm not looking for example code on how to write a metaclass (there are plenty examples of useless metaclasses out there), but real exam...
If I should be approaching this problem through a different method, please suggest so. I am creating an item based collaborative filter. I populate the db with the LinkRating2 class and for each link there are more than a 1000 users that I need to call and collect their ratings to perform calculations which I then use to create another...
I have a Python project with 2 files:
epic.py
site.py
in the epic.py I have the lines
from site import *
bark()
in site.py I have the lines
def bark():
print('arf!')
when I try to run epic.py, it returns "bark is not defined"
this is weird.
...
Hi,
What is Python's equivalent of "public static void main(String[] args) { ... }"? I remember having used it in the past and then forgot.
What I'm basically trying to remember is a function which I think included some underscores (__)...
thx
...
Hello, I am doing a little research into the feasibility of a project I have in mind. It involves doing a little forensic work on images of hard drives, and I have been looking for information on how to analyze saved windows event log files.
I do not require the ability to monitor current events, I simply want to be able to view events ...
I found this http://stackoverflow.com/questions/25461/stdbool-h-c as an answer to "where is stdbool.h on windows?" but now need to know what to do with it.
I'm actually trying to install the lazyboy python extension on windows and this is the first error that I'm receiving. So, being completely unfamiliar with this, where do I put th...
In the same vein as http://stackoverflow.com/questions/2593399/process-a-set-of-files-from-a-source-directory-to-a-destination-directory-in-pyth I'm wondering if it is possible to create a function that when given a web directory it will list out the files in said directory. Something like...
files[]
for file in urllib.listdir(dir):
...
Here is my code. I cannot get any http proxy to work. Socks proxy (socks4/5) works fine though. Any ideas why? urllib2 works fine with proxies though. I am confused. Thanks..
Code :
1 import socks
2 import httplib2
3 import BeautifulSoup
4
5 httplib2.debuglevel=4
6
7 http = httplib2.Http(proxy_info = httplib2.ProxyInfo(...
I'm using Python, for what it's worth, but will accept answers in any applicable language.
I've tried writing to /proc/$pid/cmdline, but that's a readonly file.
I've tried assigning a new string to sys.argv[0], but that has no perceptible impact.
Are there any other possibilities? My program is executing processes via os.system (equi...
How can I run hierarchical clustering on a correlation matrix in scipy/numpy? I have a matrix of 100 rows by 9 columns, and I'd like to hierarchically clustering by correlations of each entry across the 9 conditions. I'd like to use 1-pearson correlation as the distances for clustering. Assuming I have a numpy array "X" that contains ...
In a pylons controller, I would like to first return the response to the request (so that the user gets a response ASAP), and then perform some additional operations (say, updating view counts, etc.) that didn't need to happen to generate the response. What's the best-practice for doing things like this?
Thanks!
...
If you say find C-style syntax to be in the axis of evil are you just hopelessly condemned to suck it up and deal with it if you want to provide your users with cool web 2.0 applications - for example stuff that's generally done using JQuery and Ajax etc? Are there no other choices out there? We're currently building intranet apps usin...
Hi all,
how to compare the checksums in a list corresponding to a file path with the file path in the operating system In Python?
import os,sys,libxml2
files=[]
sha1s=[]
doc = libxml2.parseFile('files.xml')
for path in doc.xpathEval('//File/Path'):
files.append(path.content)
for sha1 in doc.xpathEval('//File/Hash'):
sha1s.append(...
My html webpage calls a php script to upload files to the server from a local computer as follows.
<form enctype="multipart/form-data" action="upload.php" method="POST">
<p><b><h3> <font color="#003366"> (1) Upload your reading text file. </font>
</h3> </b> </p>
<INPUT type="file" name="uploaded" size="50" >
<br/>
<input type="submi...
I'm building a page where I want to have a form that posts to an iframe on the same page. The Template looks like this:
<form action="form-results" method="post" target="resultspane" >
{% csrf_token %}
<input name="query">
<input type=submit>
</form>
<iframe src="form-results" name="resultspane" wid...