Top "Python-2.x" questions

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

Python super() raises TypeError

In Python 2.5, the following code raises a TypeError: >>> class X: def a(self): print "a" >>&…

python inheritance python-2.x super
Python exception chaining

Is there a standard way of using exception chains in Python? Like the Java exception 'caused by'? Here is some …

python exception coding-style python-2.x
Copy file with pathlib in Python

I try to copy a file with pathlib import pathlib import shutil my_file=pathlib.Path('/etc/hosts') to_…

python file copy python-2.x pathlib
How can I denote unused function arguments?

When "deconstructing" a tuple, I can use _ to denote tuple elements I'm not interested in, e.g. >>> …

python python-2.x
How to write Russian characters in file?

In console when I'm trying output Russian characters It gives me ??????????????? Who know why? I tried write to file - …

python windows unicode python-2.x python-unicode
Convert float to string in positional format (without scientific notation and false precision)

I want to print some floating point numbers so that they're always written in decimal form (e.g. 12345000000000000000000.0 or 0.000000000000012345, not …

python python-3.x floating-point number-formatting python-2.x
nonlocal keyword in Python 2.x

I'm trying to implement a closure in Python 2.6 and I need to access a nonlocal variable but it seems like …

python closures python-2.x python-nonlocal
How to accomplish relative import in python

stuff/ __init__.py mylib.py Foo/ __init__.py main.py foo/ __init__.py script.py script.py wants to import …

python python-2.x relative-path python-packaging
Why can't I use the method __cmp__ in Python 3 as for Python 2?

The following piece of code class point: def __init__(self, x, y): self.x = x self.y = y def dispc(…

python python-3.x python-2.x partial-ordering
Python List to String Conversion

This seems like a simple task and I'm not sure if I've accomplished it already, or if I'm chasing my …

python string python-2.x httplib2