nltk/nltk — Issue #77: from compat import * breaks on Python 2.6.2
Author: alexrudnick
Created: 2012-01-17 06:25:33+00:00
State: open

What version of NLTK are you using?

Python version:
Python 2.6.2 (r262:71600, Aug 31 2009, 11:32:13)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin

NLTK version is: 2.0b5

What steps will reproduce the problem?

I did a fresh checkout of NLTK from SVN. In the NLTK directory that
contains the __init__.py and compat.py doing:

>>> from compat import *
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'all'

The problem seems to be that compat.py defines __all__ as:
__all__ = ['ElementTree', 'defaultdict', 'all']

Since Python 2.6 has the 'all' function the function definition is skipped
in the compat module. Thus importing compat.all fails.

A way to fix this is to add the following line before the definition of
__all__:
all = all

The attached patch file does exactly that.

Migrated from http://code.google.com/p/nltk/issues/detail?id=437