The modules in my package have got “self” attributes that bypass __init__.pyOrganizing Python classes in modules and/or packagesDownload file from web in Python 3What's the difference between a Python module and a Python package?How to fix “Attempted relative import in non-package” even with __init__.pyPython: importing a sub‑package or sub‑moduleIs it possible to access the variables in __init__.py from the modules in the same package?How to only import sub module without exec __init__.py in the packageAutomatically import modules from a namespace packagehow to call python module with package name
'Overwrote' files, space still occupied, are they lost?
What if I don't know whether my program will be linked to a GPL library or not?
How to generate short fixed length cryptographic hashs?
In what sequence should an advanced civilization teach technology to medieval society to maximize rate of adoption?
What is the source of "You can achieve a lot with hate, but even more with love" (Shakespeare?)
Wrong Schengen Visa exit stamp on my passport, who can I complain to?
Exam design: give maximum score per question or not?
In Bb5 systems against the Sicilian, why does White exchange their b5 bishop without playing a6?
What is a "major country" as named in Bernie Sanders' Healthcare debate answers?
How would you control supersoldiers in a late iron-age society?
What organs or modifications would be needed for a life biological creature not to require sleep?
Why don't airports use arresting gears to recover energy from landing passenger planes?
How do we know that black holes are spinning?
How often is duct tape used during crewed space missions?
How to make classical firearms effective on space habitats despite the coriolis effect?
Why is the car dealer insisting on a loan instead of cash?
Wouldn't Kreacher have been able to escape even without following an order?
Madrid to London w/ Expired 90/180 days stay as US citizen
What is the word for a person who destroys monuments?
In what state are satellites left in when they are left in a graveyard orbit?
What does this Blight Tower UI mean?
What are the specifics for a Block of Incense?
Is my sink P-trap too low?
Why are two-stroke engines nearly unheard of in aviation?
The modules in my package have got “self” attributes that bypass __init__.py
Organizing Python classes in modules and/or packagesDownload file from web in Python 3What's the difference between a Python module and a Python package?How to fix “Attempted relative import in non-package” even with __init__.pyPython: importing a sub‑package or sub‑moduleIs it possible to access the variables in __init__.py from the modules in the same package?How to only import sub module without exec __init__.py in the packageAutomatically import modules from a namespace packagehow to call python module with package name
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I've built a package in Python 3. The problem is that when I import the package, every module has got those functions specified in __init__.py AND an attribute with the same name as the module (say package.package) that has got all the functions in the actual package.
I've tried to change my __init__.py files but I guess I'm not properly understanding how it works.
My package looks like that:
package/
__init__.py
package.py (same name used here)
_someprivatestuff.py
io/
__init__.py
io.py
vis/
__init__.py
vis.py
The fist __init__.py contains the following imports:
from .package import exception1
from .package import exception2
from .package import class1
from .package import class2
from .package import class3
Exceptions and classes are in package.py.
Now, if I import the module, I've got access to every other functions in package.py and the modules imported in this python files:
import package
package.class1 # this should output 'package.class1'
>>> <class 'package.package.class1'>
package.package.someprivateclass # package.package is somehow accesible
>>> <class 'package.package.someprivateclass'>
python-3.x installation package
add a comment
|
I've built a package in Python 3. The problem is that when I import the package, every module has got those functions specified in __init__.py AND an attribute with the same name as the module (say package.package) that has got all the functions in the actual package.
I've tried to change my __init__.py files but I guess I'm not properly understanding how it works.
My package looks like that:
package/
__init__.py
package.py (same name used here)
_someprivatestuff.py
io/
__init__.py
io.py
vis/
__init__.py
vis.py
The fist __init__.py contains the following imports:
from .package import exception1
from .package import exception2
from .package import class1
from .package import class2
from .package import class3
Exceptions and classes are in package.py.
Now, if I import the module, I've got access to every other functions in package.py and the modules imported in this python files:
import package
package.class1 # this should output 'package.class1'
>>> <class 'package.package.class1'>
package.package.someprivateclass # package.package is somehow accesible
>>> <class 'package.package.someprivateclass'>
python-3.x installation package
add a comment
|
I've built a package in Python 3. The problem is that when I import the package, every module has got those functions specified in __init__.py AND an attribute with the same name as the module (say package.package) that has got all the functions in the actual package.
I've tried to change my __init__.py files but I guess I'm not properly understanding how it works.
My package looks like that:
package/
__init__.py
package.py (same name used here)
_someprivatestuff.py
io/
__init__.py
io.py
vis/
__init__.py
vis.py
The fist __init__.py contains the following imports:
from .package import exception1
from .package import exception2
from .package import class1
from .package import class2
from .package import class3
Exceptions and classes are in package.py.
Now, if I import the module, I've got access to every other functions in package.py and the modules imported in this python files:
import package
package.class1 # this should output 'package.class1'
>>> <class 'package.package.class1'>
package.package.someprivateclass # package.package is somehow accesible
>>> <class 'package.package.someprivateclass'>
python-3.x installation package
I've built a package in Python 3. The problem is that when I import the package, every module has got those functions specified in __init__.py AND an attribute with the same name as the module (say package.package) that has got all the functions in the actual package.
I've tried to change my __init__.py files but I guess I'm not properly understanding how it works.
My package looks like that:
package/
__init__.py
package.py (same name used here)
_someprivatestuff.py
io/
__init__.py
io.py
vis/
__init__.py
vis.py
The fist __init__.py contains the following imports:
from .package import exception1
from .package import exception2
from .package import class1
from .package import class2
from .package import class3
Exceptions and classes are in package.py.
Now, if I import the module, I've got access to every other functions in package.py and the modules imported in this python files:
import package
package.class1 # this should output 'package.class1'
>>> <class 'package.package.class1'>
package.package.someprivateclass # package.package is somehow accesible
>>> <class 'package.package.someprivateclass'>
python-3.x installation package
python-3.x installation package
asked Mar 28 at 12:54
carrascocarrasco
258 bronze badges
258 bronze badges
add a comment
|
add a comment
|
1 Answer
1
active
oldest
votes
package.package
is a module, it has functions in it, so you can access them as package.package.someprivateclass
. Just because you've imported some names from .package
into __init__.py
doesn't mean that the names you haven't imported will be hidden.
Thank you for your response, that makes sense. So would it be a good practice to rename package.py to something like core.py or is it ok the way it is? (Obviously 'package' isn't the real name of the package).
– carrasco
Mar 29 at 7:34
package.package
is odd, I would change it.
– Ned Batchelder
Mar 29 at 11:48
add a comment
|
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55398186%2fthe-modules-in-my-package-have-got-self-attributes-that-bypass-init-py%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
package.package
is a module, it has functions in it, so you can access them as package.package.someprivateclass
. Just because you've imported some names from .package
into __init__.py
doesn't mean that the names you haven't imported will be hidden.
Thank you for your response, that makes sense. So would it be a good practice to rename package.py to something like core.py or is it ok the way it is? (Obviously 'package' isn't the real name of the package).
– carrasco
Mar 29 at 7:34
package.package
is odd, I would change it.
– Ned Batchelder
Mar 29 at 11:48
add a comment
|
package.package
is a module, it has functions in it, so you can access them as package.package.someprivateclass
. Just because you've imported some names from .package
into __init__.py
doesn't mean that the names you haven't imported will be hidden.
Thank you for your response, that makes sense. So would it be a good practice to rename package.py to something like core.py or is it ok the way it is? (Obviously 'package' isn't the real name of the package).
– carrasco
Mar 29 at 7:34
package.package
is odd, I would change it.
– Ned Batchelder
Mar 29 at 11:48
add a comment
|
package.package
is a module, it has functions in it, so you can access them as package.package.someprivateclass
. Just because you've imported some names from .package
into __init__.py
doesn't mean that the names you haven't imported will be hidden.
package.package
is a module, it has functions in it, so you can access them as package.package.someprivateclass
. Just because you've imported some names from .package
into __init__.py
doesn't mean that the names you haven't imported will be hidden.
answered Mar 28 at 21:52
Ned BatchelderNed Batchelder
275k55 gold badges466 silver badges584 bronze badges
275k55 gold badges466 silver badges584 bronze badges
Thank you for your response, that makes sense. So would it be a good practice to rename package.py to something like core.py or is it ok the way it is? (Obviously 'package' isn't the real name of the package).
– carrasco
Mar 29 at 7:34
package.package
is odd, I would change it.
– Ned Batchelder
Mar 29 at 11:48
add a comment
|
Thank you for your response, that makes sense. So would it be a good practice to rename package.py to something like core.py or is it ok the way it is? (Obviously 'package' isn't the real name of the package).
– carrasco
Mar 29 at 7:34
package.package
is odd, I would change it.
– Ned Batchelder
Mar 29 at 11:48
Thank you for your response, that makes sense. So would it be a good practice to rename package.py to something like core.py or is it ok the way it is? (Obviously 'package' isn't the real name of the package).
– carrasco
Mar 29 at 7:34
Thank you for your response, that makes sense. So would it be a good practice to rename package.py to something like core.py or is it ok the way it is? (Obviously 'package' isn't the real name of the package).
– carrasco
Mar 29 at 7:34
package.package
is odd, I would change it.– Ned Batchelder
Mar 29 at 11:48
package.package
is odd, I would change it.– Ned Batchelder
Mar 29 at 11:48
add a comment
|
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55398186%2fthe-modules-in-my-package-have-got-self-attributes-that-bypass-init-py%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown