Understand Python Path — Import Variable From __init__.py (update)

This is an update for How to (Python) get value from __init__ in same dir | by 洪健翔 Hung, Chien-hsiang | Aug, 2022 | Medium. Make sure you have read the previous one. Let’s get started!

Photo by AltumCode on Unsplash

Dir Structure:

—ModuleName

| — __init__.py

| — bar.py

__init__.py:

bar.py:

This way you can successfully import the var from __init__.py when both testing and production using.

original q: Can I use __init__.py to define global variables?

--

--

Visit my blog for more https://chienhsiang-hung.github.io/blog/

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store