0

I have a python project with a package, where the tree looks like this:

my_package
├── __init__.py
├── A.py
└── B.py

I would like to call several objects from A and B at once (from different files in the same command), is something "like" this posible?:

from my_package import ( # or some other syntax of course
    A_object_1,
    A_object_2,
    B_object_1
)

Thanks

Ivan
  • 1,352
  • 2
  • 13
  • 31
  • Does this answer your question? [How do I import other Python files?](https://stackoverflow.com/questions/2349991/how-do-i-import-other-python-files) – Gameplay Dec 14 '22 at 14:09
  • @Gameplay no, my question is a bit more specific, is it possible to get objects from two different files with the same import command? – Ivan Dec 14 '22 at 14:19
  • I'm pretty sure it's not possible. It would be quite confusing if it was actually. What is wrong with separate imports though? – Gameplay Dec 14 '22 at 14:28
  • @Gameplay my usecase is similar to this: imagine the package `geometry` that has the submodules `basicFigures` (i.e. `point`) and `complexFigures` (i.e. `star`). It could be nice to import `point` and `star` together – Ivan Dec 14 '22 at 14:47
  • "Not possible" is also an answer :) – Ivan Dec 14 '22 at 14:48
  • Well let's wait, maybe someone else knows something I don't in that matter :) You can always use `__init__.py` to organize that and in your file just "have those names" imported already. – Gameplay Dec 14 '22 at 14:49

0 Answers0