0

For example:

import foo
...

In foo.py:

from bar import baz
def qux(x):
    ...

How do I make it so you can't do from foo import baz in the main file?

Cortex
  • 1
  • 1
  • You may try to use @property. This [answer](https://stackoverflow.com/a/51052134/14772681) explained it and othe roptions very well. – rd9911 May 22 '21 at 07:45
  • 3
    Does this answer your question? [Does Python have “private” variables in classes?](https://stackoverflow.com/questions/1641219/does-python-have-private-variables-in-classes). To make this explicit: Try in *foo.py*: `from bar import baz as __baz` and replace `baz` with `__baz` elsewhere in that file where `baz` is referenced – Booboo May 22 '21 at 11:03

0 Answers0