Top "Python-2.x" questions

For questions about Python programming that are specific to version 2.x of the language.

What is the best way to remove accents (normalize) in a Python unicode string?

I have a Unicode string in Python, and I would like to remove all the accents (diacritics). I found on …

python python-3.x unicode python-2.x diacritics
Python - 'ascii' codec can't decode byte

I'm really confused. I tried to encode but the error said can't decode.... >>> "你好".encode("utf8") Traceback (most …

python python-2.7 unicode python-2.x python-unicode
How to use XPath in Python?

What are the libraries that support XPath? Is there a full implementation? How is the library used? Where is its …

python xml dom xpath python-2.x
How do I keep Python print from adding newlines or spaces?

In python, if I say print 'h' I get the letter h and a newline. If I say print 'h', …

python printing formatting python-2.x
Web-scraping JavaScript page with Python

I'm trying to develop a simple web scraper. I want to extract text without the HTML code. In fact, I …

python web-scraping python-2.x urlopen
Relative imports for the billionth time

I've been here: http://www.python.org/dev/peps/pep-0328/ http://docs.python.org/2/tutorial/modules.html#packages Python packages: …

python python-2.7 import python-2.x relative-path
How to run multiple Python versions on Windows

I had two versions of Python installed on my machine (versions 2.6 and 2.5). I want to run 2.6 for one project and 2.5 …

python windows python-3.x compatibility python-2.x
Printing without newline (print 'a',) prints a space, how to remove?

I have this code: >>> for i in xrange(20): ... print 'a', ... a a a a a a a …

python string printing python-2.x
Setting the correct encoding when piping stdout in Python

When piping the output of a Python program, the Python interpreter gets confused about encoding and sets it to None. …

python encoding terminal stdout python-2.x
Why should we NOT use sys.setdefaultencoding("utf-8") in a py script?

I have seen few py scripts which use this at the top of the script. In what cases one should …

python encoding utf-8 python-2.x sys