I have a Python web client that uses urllib2. It is easy enough to add HTTP headers to my outgoing requests. I just create a dictionary of the headers I want to add, and pass it to the Request initializer.
However, other "standard" HTTP headers get added to the request as well as the custom ones I explicitly add. When I sniff the requ...
Duplicate
http://stackoverflow.com/questions/478947/what-are-some-good-resources-for-learning-about-neural-networks
I'm looking for a good (beginner level) reference book (or website) on different types of Neural Nets/their applications/examples. I don't have any particular application in mind, I'm just curious as to how I can mak...
I have a string that can be a hex number prefixed with "0x" or a decimal number without a special prefix except for possibly a minus sign. "0x123" is in base 16 and "-298" is in base 10.
How do I convert this to an int or long in Python?
I don't want to use eval() since it's unsafe and overkill.
...
I am trying to create a graphical spectrum analyzer in python.
I am currently reading 1024 bytes of a 16 bit dual channel 44,100 Hz sample rate audio stream and averaging the amplitude of the 2 channels together. So now I have an array of 256 signed shorts. I now want to preform a fft on that array, using a module like numpy, and use ...
In Perl 5.10, I can say:
sub foo () {
state $x = 1;
say $x++;
}
foo();
foo();
foo();
...and it will print out:
1
2
3
Does Python have something like this?
...
I've got a Perl function which takes a timestamp and returns either the unchanged timestamp (if it's never seen it before) or otherwise, it appends some letters to make it unique:
sub uniqify($) {
my $timestamp = shift;
state $last_ts = -1;
state $next_letter = 'A';
if ($timestamp == $last_ts) {
$timestamp .= $next_letter+...
On college, I needed to create a virtual reality software, and used this Python API to access the stream from the webcam which I came to know through this tutorial. Found out, though, it needed a workaround to work properly.
I remember the stream was a bit slow with resolutions higher than 320x240 but I guess it was a problem on the web...
What is a good way to find the index of an element in an array in python?
Note that the array may not be sorted.
Is there a way to specify what comparison operator to use?
...
Hi, I have a question. I'd like to send a continuous streams of byte to some host for certain amount of time (let's say 1 minute) using python.
Here is my code so far:
#! /usr/bin/env python
import socket
import thread
import time
IP = "192.168.0.2"
PADDING = "a" * 1000 #assu...
I have two files, one is in the webroot, and another is a bootstrap located one folder above the web root (this is CGI programming by the way).
The index file in the web root imports the bootstrap and assigns a variable to it, then calls a a function to initialize the application. Everything up to here works as expected.
Now, in the bo...
Hi,
i'm looking for a C++ replacement of the Python PubSub Library in which i don't have to connect a signal with a slot or so, but instead can register for a special Kind of messages, without knowing the object which can send it.
...
Is it built-in in Sphinx?
...
I am learning mechanize.
mechanize is a python module to automate web browsing. One of its features is automated handling of cookies. I would like a hint about the way to dump the cookies for a mechanize.Browser instance. I can't seem to figure this out myself. I need this for debug purposes.
...
Hi,
I'm using this code to get standard output from an external program:
>>> from subprocess import *
>>> command_stdout = Popen(['ls', '-l'], stdout=PIPE).communicate()[0]
The communicate() method returns an array of bytes:
>>> command_stdout
b'total 0\n-rw-rw-r-- 1 thomas thomas 0 Mar 3 07:03 file1\n-rw-rw-r-- 1 thomas thomas 0...
I have the following code :
what = re.match("get|post|put|head\s+(\S+) ",data,re.IGNORECASE)
and in the data variable let's say I have this line :
GET some-site.com HTTP/1.0 ...
If I stop the script in the debugger, and inspect the what variable, I can see it only matched GET. Why doesn't it match some-site.com ?
...
I want to automatically add entries to python's sys.path variable when run by my user in linux.
Is there something I can tweak in my home directory to get it done?
...
Is there a way to debug a regular expression in Python? And I'm not referring to the process of trying and trying till they work :)
EDIT: here is how regexes can be debugged in perl :
use re 'debug';
my $str = "GET http://some-site.com HTTP/1.1";
if($str =~/get\s+(\S+)/i) {
print "MATCH:$1\n";
}
The code above produces the foll...
I am looking for any resources that gives examples of Best Practices, Design patterns and the SOLID principles using Python.
...
I'm writing a python application that will make heavy use of a graph data structure. Nothing horribly complex, but I'm thinking some sort of graph/graph-algorithms library would help me out. I've googled around, but I don't find anything that particularly leaps out at me.
Anyone have any good recommendations?
...