Message from Python discussions

December 2018

— How to create a sqlite database locally in the folder where the script is running?

— 

Hello everyone!
I have next structure of files:
app
main.py
pack1
__init__.py
pack1_1
__init__.py
module1_1a.py
When I am importing the module:
`
import pack1.pack1_1.module1_1a
# sys.modules
print(“pack1.pack1_1.module1_1a” in sys.modules) # True
print(“pack1.pack1_1” in sys.modules) # True
print(“pack1” in sys.modules) # True

# globals()
print(“pack1.pack1_1.module1_1a” in globals()) # False
print(“pack1.pack1_1” in globals()) # False
print(“pack1” in globals()) # True
`
With sys.modules I understand why.
But I can’t understand why it works with globals()?

— It does not work on my phone.

— 


app
main.py
pack1
__init__.py
pack1_1
__init__.py
module1_1a.py


When I am importing the module:


import pack1.pack1_1.module1_1a
# sys.modules
print(“pack1.pack1_1.module1_1a” in sys.modules) # True
print(“pack1.pack1_1” in sys.modules) # True
print(“pack1” in sys.modules) # True

# globals()
print(“pack1.pack1_1.module1_1a” in globals()) # False
print(“pack1.pack1_1” in globals()) # False
print(“pack1” in globals()) # True

Message permanent page

— Just helping ._.

— Thank you

— Sry

— Got to know .

— +

— Hello.How can i run python2 intepreter inside a python3 script?

— I guess with os.system?

— Why on earth