import urllib2, cookielib
import ClientForm
from BeautifulSoup import BeautifulSoup
first_name = "Jonas"
last_name = "Carlsson"
'''request url'''
url = 'http://www.ratsit.se/BC/Search.aspx'
cookiejar = cookielib.LWPCookieJar()
cookiejar = urllib2.HTTPCookieProcessor(cookiejar)
opener = urllib2.build_opener(...
hi all, how you must configure Apache 2.2 or mod_python?, to avoid the following error:
MOD_PYTHON ERROR
ProcessId: 5399
Interpreter: '127.0.1.1'
ServerName: '127.0.1.1'
DocumentRoot: '/var/www'
URI: '/cgi-bin/wps/'
Location: None
Directory: '/usr/lib/cgi-bin/'
Filename: '/usr/lib/cgi-bin/wps/'
...
I have the following Tkinter option menu and have two questions.First, how do I change the background color of the selected option in the popupmenu? Secondly, how do I add separators to this menu?
Snippet:
TL.selectedP = Tkinter.StringVar()
TL.opt1 = Tkinter.OptionMenu(TL.separator1, TL.selectedP,'Normal', 'White','Black', 'Bl...
I have created a wx.grid.Grid with a wx.grid.PyGridTableBase derived class to provide its data. I want to also to control the editors used on the table. Towards that end I defined the following method
def GetAttr(self, row, col, kind):
attr = wx.grid.GridCellAttr()
if col == 0:
attr.SetEditor( wx.grid.GridCellChoiceEdito...
inspect.getmembers(object[, predicate])
Return all the members of an object in a list of (name, value) pairs sorted by name.
I want to use this method, but I don't want the members to be sorted. I want them returned in the same order they were defined. Is there an alternative to this method?
Use case:
Creating a form like so:
...
I have a "Category" model, and a "Project" model, which contains a ForeignKey to "Category." So each Project can only belong to one Category.
I want to create a list that ends up looking like the following:
Category 1
Project 1
Project 2
Category 2
Project 3
Project 4
etc.
I think the following psuedocode will work:
<ul class="cate...
I'm building a form class in python for producing and validating HTML forms. Each field has an associated widget which defines how the field is rendered.
When the widget is created, it is passed in a (default) value so that it knows what to display the first time it is rendered. After the form is submitted, the widget is asked for a val...
I have a texture with a 3x9 repeating section. I don't want to store the tesselated 1920x1080 image that I have for the texture, I'd much rather generate it in code so that it can be applied correctly at other resolutions. Any ideas on how I can do this? The original texture is here: http://img684.imageshack.us/img684/6282/matte1.png
I ...
I have an application that opens multiple children widgets as separate windows, something like this: window1 opens window 2 which opens window 3 (simplified form).
In the main window I have set CTRL+Q as the quit shortcut. Below is a stripped down example of the main class.
class MainWindow(QtGui.QMainWindow):
def __init__(self):
...
I need to make both a Control-Z and Shift-Control-Z function in a tkinter text widget, so that one may undo and redo things. Anyone have any Idea?
...
Hello,
I'm using BeautifulSoup to do some screen-scraping. My problem is this:
I need to extract specific things out of a paragraph. An example:
<p><b><a href="/name/abe">ABE</a></b> <font class="masc">m</font> <font class="info"><a href="/nmc/eng.php" class="usg">English</a>, <a href="/nmc/jew.php" class="usg">Hebrew</a>...
I have an Image, I'd like to replace all the pixels of one color with those in a different color, what is the simplest way to go about that?
More or less I have an image in tkinter, and when a button is pressed I want the color to change.
...
Where?
I'm trying google and any of the proxys I've tried worked...
I'm trying urllib.open with it...
I don't know if urllib need some special proxy type or something like that...
Thank you
ps: I need some proxies to ping a certain website and not got banned from my ip
...
Let's say I have a base class defined as follows:
class Form(object):
class Meta:
model = None
method = 'POST'
Now a developer comes a long and defines his subclass like:
class SubForm(Form):
class Meta:
model = 'User'
Now suddenly the method attribute is lost. How can I "get it back" without forcing...
I need to extract financial price data from a binary file. This price data is normally extracted by a piece of C# code. The biggest problem I'm having is getting a meaningful datetime.
The binary data looks like this:
'\x14\x11\x00\x00{\x14\xaeG\xe1z(@\x9a\x99\x99\x99\x99\x99(@q=\n\xd7\xa3p(@\x9a\x99\x99\x99\x99\x99(@\xac\x00\x19\x00...
I'm looking to send an SMS with the Twilio api, but I'm getting the following error:
"unknown url type: https"
I've recompiled python with Openssl, so my code runs fine from the python interpretor, but whenever I try to run it in one of my django views I get this error. Here is my code from my view:
def send_sms(request):
recipient ...
Is there a cross-platform Python library for audio playback available? The operating systems I am targeting are (in order of importance) Windows, Linux, and Mac OSX. The file formats which need to be supported are (in order of importance) MP3, OGG, WAV, and FLAC. Does something like this exist?
I have tried a few of the Python libraries...
Hello
I'm having some trouble developing an algorithm to determine the minimum of a list of n elements. It's not the case of finding the minimum of an array of length n, that's simple:
min = A[0]
for i in range(1, len(A)):
if min > A[i]: min = A[i]
print min
But my list contains objects:
class Object:
def __init__(self, some...
Trying to get a handle on the FTP library in Python. :)
Got this so far.
from ftplib import FTP
server = '127.0.0.1'
port = '57422'
print 'FTP Client (' + server + ') port: ' + port
try:
ftp = FTP()
ftp.connect(server, port, 3)
print 'Connected! Welcome msg is \"' + ftp.getwelcome() + '\"'
ftp.cwd('\\')
x = '1'...
Hey all,
I've been teaching myself python and cgi scripting, and I know that your basic script looks like
#!/usr/local/bin/python
import cgi
print "Content-type: text/html"
print
print "<HTML>"
print "<BODY>"
print "HELLO WORLD!"
print "</BODY>"
print "</HTML>"
My question is, if I have a big HTML file I want to display in python (...