'How to directly import nested item in Python?
Let's say i have a src folder with Player.py file, that has class PlayVideo in it. Can I directly import that class from main.py file that is in same folder as src?
Normally, to use that class I would do
from src import Player
Player.PlayVideo("videofile.mp4")
Is it possible to directly import the PlayVideo class?
Solution 1:[1]
import matplotlib.pyplot as plt
The previous is an extremely common import. I'd guess your answer would be:
import src.Player.PlayVideo as PlayVideo
It works for something like:
import statsmodels.regression.linear_model as line
Hope it helps!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Soya Bjorlie |
