With BeautifulSoup 3.1.0.1 and Python 2.5.2, and trying to parse a web page in French. However, as soon as I call findAll, I get the following error:
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 1146: ordinal not in range(128)
Below is the code I am currently running:
import urllib2
from BeautifulSoup i...
I have a Python function that takes a numeric argument that must be an integer in order for it behave correctly. What is the preferred way of verifying this in Python?
My first reaction is to do something like this:
def isInteger(n):
return int(n) == n
But I can't help thinking that this is 1) expensive 2) ugly and 3) subject to ...
Hi,
Basically I'm asking the same question as this guy: http://stackoverflow.com/questions/72852/how-to-do-relative-imports-in-python
But no one gave him a correct answer. Given that you are inside a subfolder and you want to go up a directory and then into ANOTHER subfolder, doing what they suggested does not work (as the OP pointed o...
I have a medium sized Django project, (running on AppEngine if it makes any difference), and have all the strings living in .po files like they should.
I'm seeing strange behavior where certain strings just don't translate. They show up in the .po file when I run make_messages, with the correct file locations marked where my {% trans %...
I just started trying out NetBeans 6.5 with Python support. I like that the IDE provides the docstring documentation for a function/method in a popup when it's auto-completing, but is there any other way to view docstrings, either by mousing over a function/method name, or clicking somewhere? I just can not seem to find a way to do this....
Is there a way to use the DPAPI (Data Protection Application Programming Interface) on Windows XP with Python?
I would prefer to use an existing module if there is one that can do it. Unfortunately I haven't been able to find a way with Google or Stack Overflow.
EDIT: I've taken the example code pointed to by "dF" and tweaked it into ...
I have a list/queue of 200 commands that I need to run in a shell on a Linux server.
I only want to have a maximum of 10 processes running (from the queue) at once. Some processes will take a few seconds to complete, other processes will take much longer.
When a process finishes I want the next command to be "popped" from the queue a...
I'm already proficient in PHP and Javascript, but for a project a client is insisting that it be done in Python instead. Its a good opportunity, so I've agreed to learn Python.
My questions are:
How easy/hard will it be to build AJAX powered web applications in Python compared to PHP
what are the main differences in the two languages...
I'm dying to get started Django but I'm really struggling with the initial setup. I have Python/MySql/Apache2.2/mod_python installed. Now I'm trying to create a proper directory structure and then update Django and Apache settings.py/httpd docs respectively. Specifically the location tag in the latter. Django and Python are based on simp...
In PHP you can just use $_POST for POST and $_GET for GET (Query string) variables. What's the equivalent in Python?
...
This seems like such a trivial problem, but I can't seem to pin how I want to do it. Basically, I want to be able to produce a figure from a socket server that at any time can give the number of packets received in the last minute. How would I do that?
I was thinking of maybe summing a dictionary that uses the current second as a key, a...
I have two lists of objects. Each list is already sorted by a property of the object that is of the datetime type. I would like to combine the two lists into one sorted list. Is the best way just to do a bubble sort or is there a smarter way to do this in Python?
...
I am quite a heavy user of wxWidgets, partly because of licensing reasons.
How do you see the future of wxWidgets in prospect of the recent announcement of Qt now being released under LGPL?
Do you think wxwidget is still a good technical choice for new projects ? Or would you recommand adopting Qt, because it is going to be a de-facto ...
Hi, I wrote an application server (using python & twisted) and I want to start writing some tests. But I do not want to use Twisted's Trial due to time constraints and not having time to play with it now. So here is what I have in mind: write a small test client that connects to the app server and makes the necessary requests (the commun...
I have a Python regular expression that contains a group which can occur zero or many times - but when I retrieve the list of groups afterwards, only the last one is present. Example:
re.search("(\w)*", "abcdefg").groups()
this returns the list ('g',)
I need it to return ('a','b','c','d','e','f','g',)
Is that possible? How can I do i...
Hi,
I have a list with 15 numbers in, and I need to write some code that produces all 32,768 combinations of those numbers.
I've found some code (by googling) that apparently does what I'm looking for, but I found the code fairly opaque and am wary of using it. Plus I have a feeling there must be a more elegant solution.
The only thi...
I'm making a script parser in python and I'm a little stuck. I am not quite sure how to parse a line for all its functions (or even just one function at a time) and then search for a function with that name, and if it exists, execute that function short of writing a massive list if elif else block....
EDIT
This is for my own scripting ...
I've not used Unit Tests before other than a quick introduction in a Uni course. I'm currently writing an application though and would like to teach myself TDD in the process. The problem is, I've no idea what to test or really how.
I'm writing a Django application, and so far have only created the models (and customised the admin appli...
I need to batch create images with text. Requirements:
arbitrary size of bitmap
PNG format
transparent background
black text anti-aliased against transparency
adjustable character spacing
adjustable text position (x and y coordinates where text begins)
TrueType and/or Type1 support
Unix command line tool or Python library
So far I've...
On Unix, I can either use \r (carriage return) or \b (backspace) to print over text already visible in the shell (i.e. overwrite the current line again).
Can I achieve the same effect in a Windows command line from a Python script?
I tried the curses module but it doesn't seem to be available on Windows.
...