Skip to content

Compatibility of configparser with Python2 and Python3  #638

@Pablitosi4

Description

@Pablitosi4

Hello, I am working on migrating a project from Python 2 to Python 3, ensuring compatibility so that it works on both Python 2 and Python 3. One of the problems I encountered is that Python 2 requires import ConfigParser, while Python 3 requires import configparser.

The functionality of the new version of the your project futurize, does not solve this problem.

On your project website (https://python-future.org/imports.html), it is stated:

Note that, as of v0.16.0, python-future no longer includes an alias for the configparser module because a full backport exists (see https://pypi.org/project/configparser/).

From this, I concluded that this issue is resolved by the tools of configparser's project.

After following your link to configparsers's project, I see:

This package is a backport of the refreshed and enhanced ConfigParser from later Python versions. To use the backport instead of the built-in version, simply import it explicitly as a backport:

`from backports import configparser`

To use the backport on Python 2 and the built-in version on Python 3, use the standard invocation:

`import configparser`

For detailed documentation consult the vanilla version at http://docs.python.org/3/library/configparser.html.

However, even after installing with pip install configparser, neither the code import configparser nor the code from backports import configparser works when running on Python 2.

Can you explain how to ensure configparser's compatibility between Python 2 and Python 3 without futurize's tools?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions