Importing Your Own Python Modules Properly

preview_player
Показать описание
Today we learn how to properly import your own Python modules and also what the __init__.py file is about.

◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾
📚 Programming Books & Merch 📚

🌐 Social Media & Contact 🌐

Рекомендации по теме
Комментарии
Автор

You're confusing the term module with what is actually a package in python. Any file with a py extension is a 'module' in python. A collection of py files in a directory along with an __init__ file is a package, not a module

robbiefryers
Автор

I was looking for init usage and most of the tutorials in the wild were showing importing files just from next to the main python file.Now this is useful.Thanks.

bloodywolftr
Автор

Nice explanation, best one yet I've seen on modules!

somecallmetimelderberries
Автор

Thank you! :) I always learn something new with your videos :D Please keep it up!! Very well done :)

MrCipek
Автор

Thank you SO much. This was a difficult concept for me to grasp but so helpful. Your awesome

jameswilliams-nwlq
Автор

Is that also possible to import the modules without the "from..."?
E.g. with "import functionality" and call the functions with "functionality.add()".

In comparison when I import the "math" module I use that method and can call "math.pi" afterwards.

philipp
Автор

Thank You Sir. You went into great length to explain this concept.

saurabh
Автор

Thanks for the video and making the effort. I found it quite difficult to see which files you were editing with the editor. I have rewatched a few times, but its blowing my mind.

sirsquirrel
Автор

Quick and simple explanation thank you !

patrikpatrik
Автор

Was stuck on this for almost two days with most solutions on stack overflow and chatgpt suggesting to use absolute paths, instead of this type of relative pathing to import stuff.
Finally managed to understand it 😆

kaushiksinghrawat
Автор

THIS!! This is exactly what i have been looking for! Thank you so much

ninavanleeuwen
Автор

nice. only thing i'd add is that you can import from a parent directory using .., so it would read "from ..parent_directory import y"

aceldama
Автор

Good stuff! I did notice that if I package everything into a wheel, without adding the classes to the __init__.py I was getting ModuleNotFound errors whenever I used submodules from the package.

bla
Автор

Excellent video! I’m new to python and this is a big help

donjackson
Автор

Thank you so much for this, very clear explanation.

vedy
Автор

BROTHER, YOU ARE THE BEST!!! You oooh really helped me!! THANK YOU VERY MUCH!

swifttech
Автор

Really informative video. Thanks for recording and sharing it.

salarghaffarian
Автор

you saved me a lot of time with this video. thank you. earned my sub

Person-hbdv
Автор

Thank you very much sir .... This was badly needed...

sahilgarg
Автор

what if our module is in another directory? should we amend the system path?

amiralizadeh