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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:41:43+00:00 2026-05-13T22:41:43+00:00

I’ve just read an article that supposedly introduced me to a new concept: Up

  • 0

I’ve just read an article that supposedly introduced me to a new concept: Up to now I was sure that python packages (i.e directories with an __init__.py file) behave exactly the same as java packages, that is – little namespaces to help arrange the code (minus java’s “package” scoping).
But, according to this link:
A Short Digression Into Multi-File Modules, if I put all my files in the same “package”:

the entire collection of files is presented to other Python code as a single module — as if all the functions and classes were in a single .py

So now I thought that my whole understanding of the python “package” thing was wrong. Moreover – it’s entirely not a package, rather a “multifile module” as the author refers to it.

So, from what I understood, no matter to how many files I divide my funcs and classes inside a package, from the outside that package should appear as though I took all the code from all the files inside the package and put it in one big file with the same name as the package instead, i.e as one module.

e.g, if I have the following file structure:

/base
    /animals
        /__init__.py
        /dog.py

and in dog.py:

def bark():
    print "woof"

it should be exactly the same as having:

/base
    /animals.py

and in animals.py:

def bark():
    print 'woof'

thus, this next piece of code should run fine on both cases:

from base import animals
animals.bark()

This of course yields in the first case:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
AttributeError: 'module' object has no attribute 'bark'

What am I missing here? I see by the exception that “animals” is indeed treated as a module, but it appears i still have to explicitly state animals.dog.bark, i.e the internal file structure of the package isn’t abstracted from the outside.

Am I missing the author’s point, or just not implementing it correctly?

=== EDIT ===

Just to make sure no one misses this line in the quote:

as if all the functions and classes were in a single .py

regardless of how to actually access this funcs and classes, the above quote explicitly states that if you have a func1 in file a and func2 in file b, regardless of which path will they be accessible from, if we denote this path as X then, according to the aforementioned quote, both X.func1 and X.func2 should work.

  • 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-13T22:41:44+00:00Added an answer on May 13, 2026 at 10:41 pm

    The author has oversimplified things. He’s saying that everything under animal can be seen as being in the same module, although the fact is that names in animal.dog will be in their own namespace.

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

Sidebar

Related Questions

No related questions found

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.