__all___
is a list with a string as an element.
This string means the symbol to be exported from from <module> import *
.
For example, the following code foo.py
exports symbol bar
and baz
.
#foo.py
__all__ = ['bar', 'baz'] # specify to export bar, baz from import *
waz = 5
bar = 10
def baz(): return 'baz'
Now, when temp.py
imports foo
module
#temp.py
from fromoo import * #bar, baz imported
print bar #success
print baz #Success
exception occurred because printwaz # "waz" was not specified in __all____ on foo.py
However, if import *
without specifying _all__
, all symbols (excluding symbols that start with _
) are imported
If you clear the __all__
part of foo.py
, print waz
will run without any problems.
For this reason, set __init__
in the __init__
file.
611 GDB gets version error when attempting to debug with the Presense SDK (IDE)
581 PHP ssh2_scp_send fails to send files as intended
915 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
618 Uncaught (inpromise) Error on Electron: An object could not be cloned
574 Who developed the "avformat-59.dll" that comes with FFmpeg?
© 2024 OneMinuteCode. All rights reserved.