I am trying the following code with a particular HTML file
from BeautifulSoup import BeautifulSoup
import re
import codecs
import sys
f = open('test1.html')
html = f.read()
soup = BeautifulSoup(html)
body = soup.body.contents
para = soup.findAll('p')
print str(para).encode('utf-8')
I get the following error:
UnicodeEncodeError: 'asci...
I'd like to take user input (sometimes this will be large paragraphs) and generate a LaTeX document. I'm considering a couple of simple regular expressions that replaces all instances of "\" with "\textbackslash " and all instances of "{" or "}" with "\}" or "\{".
I doubt this is sufficient. What else do I need to do? Note: In case t...
How would I go about adding a script written in python to a c++ project? Thanks
Edit: Basically all the script does is email some data. I would like to pass the data and maybe the email address to a function written in python. Hope that clears things up..
...
Hi,
We have a project that uses HP Quality Center and one of the regular issues we face is people not updating comments on the defect.
So I was thinkingif we could come up with a small script or tool that could be used to periodically throw up a reminder and force the user to update the comments.
I came across the Open Test Architectu...
Having a snippet like this:
import yaml
class User(object):
def __init__(self, name, surname):
self.name= name
self.surname= surname
user = User('spam', 'eggs')
serialized_user = yaml.dump(user)
#Network
deserialized_user = yaml.load(serialized_user)
print "name: %s, sname: %s" % (deserialized_user.name, deserialized...
Without installing third party libraries, what kind of client\server protocols python supports out of the box ?
...
I have a python package with some C code needed to build an extension (with some non-trivial building needs). I have used SCons as my build system because it's really good and flexible.
I'm looking for a way to compile my python extensions with SCons ready to be distributed with distutils. I want that the user simply types setup.py inst...
Hi, I am learning python for a while, now I like to learn python for web, using python as a back-end of website. where and how do I start learning this:
Example usages are : connecting database and retrieve and store information from forms
...
I'm trying to split a string into a int list for further processing. But somehow I can't remove certain whitespaces in between elements of the list. The string x is supposed to have a length of 1000 instead of 1019. I tried reading the documentation for python and saw the function strip() for stripping whitespaces from strings. However, ...
Hey Stackers! :)
My Django project's directory hierarchy looks like this:
+ pybsd
|---+ devices
|---+ templates
|---+ views
|---+ interaction
|---- __init__.py
|---- geraete.py
|---- geraetemodelle.py
|---- geraetegruppen.py
|---- __init__.py
|---- ajax.py
...
I have a directory /tmp/dir with two types of file names
/tmp/dir/abc-something-server.log
/tmp/dir/xyz-something-server.log
..
..
and
/tmp/dir/something-client.log
I need append a few lines (these lines are constant) to files end with "client.log"
line 1
line 2
line 3
line 4
append thes...
Hi,
I'm wondering what is the best time to register a font for use in reportlab. I added the following line into my settings.py:
pdfmetrics.registerFont(TTFont('Calibri', FONT_DIR + '/fonts/Calibri.ttf'))
After this call the font is available for pdf generation. But it occurs that after a few days the font is not available anymore an...
Hi,
How do I make syncdb execute SQL queries (for table creation) defined by me, rather then generating tables automatically.
I'm looking for this solution as some particular models in my app represent SQL-table-views for a legacy-database table.
So, I've created their SQL-views in my django-DB like this:
CREATE VIEW legacy_series AS S...
I am looking for a good example of how to achieve the following:
I would like to use get_or_create to check whether an object already exists in my database. If it does not, then it will be created. If it does exist, then I will not create the new object, but need to raise a form error to inform the user that they need to enter different...
As I just found out import package does not make the package's modules available through package.module. The same obviously holds true for from package import subpackage as well as from package import *
What's the purpose of importing a package at all then if I can't access its submodules but only the objects defined in __init__.py?
It...
If there exists an old data of a model say ,
query=Emp.objects.filter(pk=profile.id)
Is there a easier way to copy the same values into the same model again..
Now that the id will be different so..
I have this requirement.
Thanks..
...
Hi
I'm building a graph with many nodes, around 3000. I wrote a simple python program to do the trick with graphviz, but it gives me segmentation fault and I don't know why, if the graph is too big or if i'm missing something.
The code is:
#!/usr/bin/env python
# Import graphviz
import sys
sys.path.append('..')
sys.path.append('/us...
Hi folks,
is there a difference between using FAPWS3 and MOD_WSGI when dealing with Django?
FAPWS3 seems alot faster when serving requests toward Python scripts. I would like to know if I'm missing out anything. :)
Any ideas?
...
Possible Duplicate:
Remove items from a list while iterating in Python
My problem is simple: I have a long list of elements that I want to iterate through and check every element against a condition. Depending on the outcome of the condition I would like to delete the current element of the list, and continue iterating over it...
In *nix systems one can use which to find out the full path to a command. For example:
$ which python
/usr/bin/python
or whereis to show all possible locations for a given command
$ whereis python
python: /bin/python.exe /bin/python2.5-config /usr/bin/python.exe /usr/bin/python2.5-config /lib/python2.4 /lib/python2.5 /usr/lib/python...