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 6776323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:00:50+00:00 2026-05-26T16:00:50+00:00

While writing code, I often run into the problem of addressing trivial dependancies. For

  • 0

While writing code, I often run into the problem of addressing trivial dependancies. For example, let’s take the layout of a memoizer object I’ve recently written. My directory structure looks like this:

memoizer/
  memoizer.py
  tests.py
  strategies/
    __init__.py
    perfect.py
    mru.py
    queue.py
README

The problem is specifically, with mru.py. mru.py contains a MRU class which uses a Queue defined in queue.py. Clearly though, a queue isn’t a strategy for a memoizer, and it doesn’t make any sense to put it under strategies.

One idea I had was to set up my code to look something like this:

memoizer/
  memoizer.py
  tests.py
  strategies/
    __init__.py
    perfect.py
    mru/
      __init__.py
      mru.py
      queue.py
README

The problem with this set up though is that now the user has to know that mru is in a subpackage.

Another idea was to arrange the structure like this:

memoizer/
  memoizer.py
  tests.py
  strategies/
    __init__.py
    perfect.py
    mru.py
    dependencies/
      __init__.py
      queue.py
README

This would solve my problem, but it intuitively seems like the wrong way to do it.

What is the right way to organize my files to account for this inconsistency?

  • 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-26T16:00:51+00:00Added an answer on May 26, 2026 at 4:00 pm

    I would suggest a variation of the second structure:

    memoizer/
      memoizer.py
      tests.py
      strategies/
        __init__.py
        perfect.py
        mru/
          __init__.py <- This is what used to be mru.py
          queue.py
    README
    

    Then the user can just import memoizer.strategies.mru.

    That’s the quick and easy way of doing it. However, you could keep the original mru.py file, and expose items from it in your __init__.py like so:

    import mru as _mru
    
    SomeClass = _mru.SomeClass
    # etc...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While striving for const-correctness, I often find myself writing code such as this class
I have come across an annoying problem while writing some PHP4 code. I renamed
I've encountered a problem while writing code in Delphi. Namely I can't get acces
While writing code in a file that would comprise of PHP, HTML, CSS &
While writing code, it is pretty common to request a page with an appended
I got this doubt while writing some code. Is 'bool' a basic datatype defined
While writing some C code, I decided to compile it to assembly and read
Sometimes while writing Java in Eclipse, I write code that generates warnings. A common
I find myself writing code that looks like this a lot: set<int> affected_items; while
I'm writing some code that looks like this: while(true) { switch(msg->state) { case MSGTYPE:

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.