Skip to content

Commit ed52616

Browse files
committed
Python note: One way to control relative import
1 parent f960f5f commit ed52616

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Python.adoc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,19 @@ Now whenever you want to use Python from Anaconda:
286286
source <anaconda-destination>/bin/activate <anaconda-destination>
287287
----
288288

289+
=== One way to control relative import
290+
291+
[source,python,linenums]
292+
----
293+
import sys
294+
import os
295+
sys.path.insert(0, os.path.abspath(
296+
os.path.join(os.path.dirname(__file__), "../..")
297+
))
298+
299+
import fully.qualified.module.path
300+
----
301+
289302
== FAQs
290303

291304
=== Why global interpreter lock (GIL) in CPython?

0 commit comments

Comments
 (0)