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

  • SEARCH
  • Home
  • 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 4607934
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:46:22+00:00 2026-05-22T00:46:22+00:00

The Question I would like to know if there is a standard convention for

  • 0

The Question
I would like to know if there is a standard convention for the naming of Python directories that plan to be imported as a module. Meaning the directory contains a blank __init__.py

Background
Up until recently I have given it little thought and named solely based on what made sense at the file system level. What got me in trouble is that what made sense at the file system level also made sense for other developers’ standalone modules. Consider the following directory:

+ drivers
    + prologix  
        - __init__.py
        - driver_a.py
        - driver_b.py
    + visa
        - __init__.py  
        - driver_a.py
        - driver_b.py
    __init__.py
    ringout.py <-- simple file to ring-out the drivers  

While this worked fine when ringing out the prologix’s drivers, I ran into an issue when trying to import my visa drivers as well as pyVisa’s ‘visa’ module. It was very easy to diagnose the problem, but the fix to rename my visa driver’s folder to ‘visa_dir’ makes the code more difficult to read (IMO).

import drivers.visa  

vs

import drivers.visa_dir  

Is there a better way to handle this?

  • 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-22T00:46:23+00:00Added an answer on May 22, 2026 at 12:46 am

    Each module’s namespace is unique, so even if you have two modules named visa as long as you avoid importing them into the same namespace with the same name you won’t have any problems. I tend to prefer absolute imports:

    import drivers.visa
    import pyVisa.visa
    

    Or you could also use as:

    from drivers import visa
    from pyVisa import visa as pyvisa
    

    …etc. Just be careful how you import things. I’d prefer (as an end-user) that you structure your modules logically within your package and not worry about pre-mangling them for me.

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

Sidebar

Related Questions

Refering to a previously asked question , I would like to know how to
In addition to this question: iPhone network performance , I would like to know
I know this isn't a programming question but I would really like the users
I know this is a weird question to ask, but I would like to
I am aware that the standard Python convention for line width is 79 characters.
There are some third party Javascript libraries that have some functionality I would like
I would like to know the answer for the following questions: Identify device types
Question 1 We would like to generate a site map for our CMS site
I would like to ask a question. Now i am training in iOS with
I would like to ask a question on theming in liferay. What would be

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.