Dear Python Experts,
I have written the following trial code to retreive the title of legislative acts from the European parliament.
import urllib2
from BeautifulSoup import BeautifulSoup
search_url = "http://www.europarl.europa.eu/sides/getDoc.do?type=REPORT&mode=XML&reference=A7-2010-%.4d&language=EN"
for number in xran...
We're using the Django Admin to maintain some data that's exported to a few of our sites. Sometimes when clicking through the standard changelist view to get a model edit form instead of being routed to the correct page we're getting the Django 404 page/template.
It was happening somewhat sporatically, and we could for a while reproduce...
I am trying to create a bunch of directories/subdirectories that I can copy files into. I am working with Python and I can't seem to find a good way to do this. I have a main path that I will branch off of. Then after that, I have Weights and No_Weights. Male and Female following. Within each of Male and Female folders, I have each e...
Do you think that it is OK to use map for an applying function to arguments list and ignore the results?
map(foo, bar)
It may appears as bug to person who is reading code.
...
I am just a beginner in python and I want to know is it possible to remove all the integer values from a list? For example the document goes like
['1','introduction','to','molecular','8','the','learning','module','5']
After the removal I want the document to look like:
['introduction','to','molecular','the','learning','module']
...
I have a custom tag in Jinja2 that I want to output something only the first time that it is called. So say I have the following template:
1. {% only_once %}
2. {% only_once %}
3. {% only_once %}
I want the output to be:
1. "I only get printed once!"
2.
3.
I'm guessing the best way to do this is to set a flag in the context of the...
While experimenting with Python's (python.org) C API, I found myself wondering how to properly spawn threads via Python's threading package when Python itself is embedded in a C program. Functions PyEval_EvalCode and kin appear to terminate threads it "owns" as soon as the C function finishes evaluating a block of Python code. Roughly, r...
Hello all,
I would like to unit test a django view by sumitting a form. The problem is that this form has a captcha field (based on django-simple-captcha).
from django import forms
from captcha.fields import CaptchaField
class ContactForm(forms.forms.Form):
"""
The information needed for being able to download
"""
las...
How can I render HTML content to GIF image?
I found how to render it to PDF using reportlab, but no luck with GIF.
I want something like xhtml2pdf.com but final result should be not in pdf, but in image.
...
I want to parse the 2 digits in the middle from a date in dd/mm/yy format but also allowing single digits for day and month.
This is what I came up with:
(?<=^[\d]{1,2}\/)[\d]{1,2}
I want a 1 or 2 digit number [\d]{1,2} with a 1 or 2 digit number and slash ^[\d]{1,2}\/ before it.
This doesn't work on many combinations i have tested ...
Hi folks,
I'm trying to iterate through fields as they are written down within my model:
currently I'm using this:
def attrs(self):
for attr, value in self.__dict__.iteritems():
yield attr, value
but the order seems pretty much random :(
Any ideas?
...
if i open a file (image) in python with
f = open('/path/to/file.jpg', 'r+')
i have the a function f.title() and i get the full path of the file back.
how can i change the opened files name/repr/title to something else?
...
Hey,
I got a google wave python robot running with an existing django app engine web app.
all works well apart from one thing. for some reason i am unable to access my datastore which is the same datastore for the django webapp.
i want to read data and store data to the django datastore from the robot.
what can i do?
...
I've never written a program, (although I've dabbled in Access and am familiar with OOP concepts), and have decided to undertake the challenge of writing myself a database program for home use. (It'll keep track of our finances and be customized to our way of doing things.) I've pretty much decided to use Python and SQLite, but that st...
I have a frame that contains (among many other things) a panel. I need to be able to explicitly set the size of the panel and have the frame with all its sizers, buttons, and everything else fit around the new size of the panel. I have tried every combination of Fit/Layout/etc I can think of, but I can never get the frame to grow/shrin...
I am writing a little utility function in Python which returns a boolean, indicating whether today is in the first week of the month.
This is what I have so far:
import calendar
import time
y, m = time.localtime(time.time())[:2]
data = calendar.month(y, m)
In [24]: type(temp)
Out[24]: <type 'str'>
In [25]: print temp
-------> print(t...
I have a text file that is tab delimited and looks like:
1_0 NP_045689 100.00 279 0 0 18 296 18 296 3e-156 539
1_0 NP_045688 54.83 259 108 6 45 296 17 273 2e-61 224
I need to parse out specific columns such as column 2.
I've tried with the co...
Following is from python website, about
random.shuffle(x[, random])
Shuffle the sequence x in place. The optional argument random is a 0-argument function returning a random float in [0.0, 1.0); by default, this is the function random().
Note that for even rather small len(x), the total number of permutations of x is large...
i want to filter some headers in a wireshark capture (converted to text format) so i can analyse these set of headers.i need a python script to do this. any help would be appreciated
...
I would like some help finding a python module that can identify a barcode within a scanned document. If anyone can help me at least come closer to finding an example of this I would be greatly appreciative.
...