Hey. I'm coding a cgi in Python, running on an IIS 7.5 web server, on Windows. I would like to get the tcp port (usually was the server environment variable REMOTE_PORT) from which the client is connecting to it.
I've tried to look up all the way throuhout the keys as in os.environ.keys() and I can get the user IP address, his browser,...
I'm currently working on a project to implement a Django interface to an existing calendar application. The calendar application has MySQL as the backend DB.
In our custom application we would like to modify/extend the data in one of the tables used by the existing calendar application e.g.
# Auto-generated by inspectdb - table used by...
Hi,
imagine that I developed the next killer application in Python using pySide and other several third party libraries.
Which tools do i need to create different installers for every OS out there (windows, osx, nix)?
...
I'm pretty new to Python and am completely confused by .join() which I have read is the preferred method for concatenating strings.
I try:
strid = repr(595)
print array.array('c', random.sample(string.ascii_letters, 20 - len(strid)))
.tostring().join(strid)
and get something like:
5wlfgALGbXOahekxSs9wlfgALGbXOahekxSs5
Why does...
Python optparse works very good when script usage is something like this
%prog [options] [args]
But I need to write help for script with 1 required argument, so usage will be like this
%prog action [options] [args]
You can see something similar when you use Subversion - its usage string is
svn <subcommand> [options] [args]
So my...
What's the best and fastest way to access a value from the previous iteration in a for loop, assuming that the object will be very large (example, a cursor object which has 100,000+ records)
Using a simple example:
tmp = [
['xyz', 335], ['zzz', 338], ['yyy', 339], ['yyy', 442],
['abc', 443], ['efg', 444], ['ttt', 44...
As described in http://stackoverflow.com/questions/1836861/how-to-update-a-django-page-without-a-page-reload, I send periodic XMLHTTPRequests from the browser to the server using JavaScript to get those pieces of the webpage that changes during the course of my application.
However, most of the time, nothing changes; the server replies ...
I'm running a for loop inside a function which is creating instances of a class to test them. instead of making new classes it appears to be reusing the same two over and over.
Is there something I'm missing about how classes and variables are handled in python methods?
how can I generate a new object for each iteration of the loop
cl...
I'm working on a small wave thingy where i need to load a wave based on an outside event. So i don't have a context to work with.
I've been looking at the python api for a while but i can't figure out the correct way to get a wave object (that i can then call CreateBlip() on) when i just have the waveid.
Is there something i've just ov...
What two things need to happen for a text box's change event to fire?
...
Okay, so I've been doing web design for about a year or two, and I've decided that I want to learn a Programming Language, because I've figured out that's what interest me more.
I start out learning Python, got about about 1/4 of the way through Dive into Python, but then decided to go onto Ruby because in the nearer future for now I'm ...
It's likely that this is just a general Python Tkinter question, not necessarily a matplotlib one.
So I'm in the midst of developing a rather large suite of plotting functionality on top of matplotlib using the Matplotlib "TkAgg" backend (Agg rendering to a Tk canvas using TkInter). I'm using some of the default zooming functionality p...
I want to create a lambda function that takes two numpy arrays and sets a slice of the first to the second and returns the newly set numpy array.
Considering you can't assign things in lambda functions is there a way to do something similar to this?
The context of this is that I want to set the centre of a zeros array to another array ...
I'm having some problems implementing an exception system in my program.
I found somewhere the following piece of code that I am trying to use for my program:
class InvalidProgramStateException(Exception):
def __init__(self, expr, msg):
self.expr = expr
self.msg = msg
I think msg must be a string message to be show...
I am playing with the euclidian distance example from programming collective intelligence book,
# Returns a distance-based similarity score for person1 and person2
def sim_distance(prefs,person1,person2):
# Get the list of shared_items
si={}
for item in prefs[person1]:
if item in prefs[person2]:
si[item]=1
# ...
My program uses genetic techniques to build equations.
It randomly assembles strings into an equation with one unknown.
"(((x + 1) * x) / (4 * 6) ** 2)"
One of the strings is: "math.factorial(random.randint(1,9))"
So an equation is typically something like:
"(((x + 1) * x) / (4 * 6) ** 2) + math.factorial(random.randint(1,9))"
Fi...
The following python module is meant to be a basis for "constant" handling in python. The use case is the following:
one groups some constants (basically "names") that belong together with their values into a dictionary
with that dictionary bound to class variable a class is created and instantinated run-time
the attributes of this cla...
Hello,
I want to simply render a built-in comment form in a template, using Django's builtin commenting module, but this returns a TemplateSyntaxError Exception.
I need help debugging this error, please, because after googling and using the Django API reference, I'm still not getting any farther.
Info:
This is the template '_post.htm...
How can one delete the very last line of a file via python?
Example File:
hello
world
foo
bar
Resulatant File:
hello
world
foo
I've created the following code to find the number of lines in the file - but I do not know how to delete the specific line number. I'm new to python - so if there is an easier way - please tell me.
try:...
What's the best method to debug Django's url configurations? Sometime it just throw out a Unhandled Exception without any hints if there is an error in urls.py
Sometimes it throws out errors like "unbalanced parenthesis" but I still dont know which line in urls.py caused the error.
...