Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6570607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:46:36+00:00 2026-05-25T14:46:36+00:00

I am developing a package with the following structure on disk: foo/ __init__.py xml.py

  • 0

I am developing a package with the following structure on disk:

foo/
   __init__.py
   xml.py
   bar.py
   moo.py

The xml.py package provides a class that does some custom XML parsing and translation for the other package components using a SAX stream parser. So it has in it:

import xml.sax
import xml.sax.handler

But when I go to use foo.xml in an application I get:

Traceback (most recent call last):
  File "testxmlparser.py", line 15, in <module>
    import foo.xml
  File "~/code/foo/xml.py", line 39, in <module>
    import xml.sax
ImportError: No module named sax

I appear to have a namespace conflict. If I rename xml.py to something else like xmlparser.py everything works as expected. But this feels like the wrong thing to do. I feel like I’m missing something fundamental about package names and resolution in Python here.

Is there a proper way to make this work that doesn’t involve me renaming the foo/xml.py file? Or is that really the only solution to the conflicting names?

Edit: The “avoid naming things the same as standard Python modules” seems…well..a mineshaft to me. That’s a moving target, the standard module set, that’s bound to change and grow over time. So unless you get really creative with your names the rename-things-until-you-find-something-that-doesn’t-conflict solutions seems poor to me. Besides, I’ve got it in a unique package name with foo already (I’m not using foo, but something that is definitely unique), shouldn’t that be enough?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T14:46:37+00:00Added an answer on May 25, 2026 at 2:46 pm

    As mentioned over here, use

    from __future__ import absolute_import
    

    and use relative imports if needed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing a package that provides an S3 class named Foo. It also provides
I am developing some convenience wrappers around another software package that defines a bash
I am developing a PHP/mysql package to add/edit questionnaire.. I want some pakage to
I am developing a Python package for dealing with some scientific data. There are
I'm developing software based on an open source package that uses external storage to
I'm developing a Visual Studio Integration Package. When I try to run the Unit
Developing a heavily XML-based Java-application, I recently encountered an interesting problem on Ubuntu Linux.
Developing a project of mine I realize I have a need for some level
I am developing an application that has to capture the key events both in
I tried to start developing for Microsoft Surface. For that I first installed Visual

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.