Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added import statements to openrocketdoc/__init__.py to allow import of modules from installed package #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

sanketdiwale
Copy link

@sanketdiwale sanketdiwale commented Dec 9, 2016

installing the package via python setup.py install or python setup.py
develop did not copy the python scripts to the installed directory if
they were not explicitly imported in init.py

Sanket Diwale added 2 commits December 9, 2016 10:53
…ripts

installing the package via python setup.py install or python setup.py
develop did not copy the python scripts to the installed directory if
they were not imported in __init__.py
@coveralls
Copy link

Coverage Status

Coverage increased (+0.02%) to 91.055% when pulling 7d3db5b on sanketdiwale:master into 7df113d on open-aerospace:master.

@natronics
Copy link
Member

Thanks!

Is this to fix any particular problem your having? I usually try to avoid the from foo import * pattern because if two things have the same name then there can be problems! In particular a file loader and a file writer might have the same name, so you really would want to import them separately like this:

from openrocketdoc import loaders
from openrocketdoc import writers

I think this should work without having any imports in the main __init__.py file.

@natronics
Copy link
Member

Oh! Or I could have my setup.py wrong. I might need to list extra modules there. All the tests work and I haven't had a problem running it though, so let me know if there is something that isn't working for you.

@sanketdiwale
Copy link
Author

sanketdiwale commented Dec 10, 2016

Hi natronics,

I tried doing "from openrocketdoc import loaders" without adding the import lines to the init.py file. And this works fine. Sorry about the mixup.

I had initially tried just "import openrocketdoc" and then tried to declare a object as "p =openrocketdoc.loaders.RockSimEngine()". This was giving me "AttributeError: 'module' object has no attribute 'loaders'". Which I fixed using the import statements in the init.py.
However I guess this isn't the correct way to create the loaders object. I guess you should reject the pull request.

I agree with your statement " I usually try to avoid the from foo import * pattern because if two things have the same name then there can be problems! ". Sorry about the mixup.

Best,
Sanket

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants