Python: Modules and Packages

  Рет қаралды 83,552

Damian T. Gordon

Damian T. Gordon

Күн бұрын

Пікірлер: 58
@moorelo
@moorelo 5 жыл бұрын
Thank you for explaining modules so clearly. I starting programming in FORTRAN IV in the 80s, Python has me excited about programming again.
@RaynerDaCruz
@RaynerDaCruz 4 жыл бұрын
@9:20 Wouldn't the first snippet of code result in a ModuleNotFoundError since point-call.Point() is not prefixed with Drawing? Like this, Drawing.point-call.Point()?
@wiliextreme
@wiliextreme 2 жыл бұрын
thanks for this great video, coming from nodejs I found it pretty confusing how python imports work but now I get it
@ryansossou646
@ryansossou646 3 жыл бұрын
Hey Damian, this is exactly what I was looking for, I just started working on a big project with python but package and modules management was really confused, now everything is clear, you're the best Damian, thanks for bringing those free resources for the community
@ratonmagico
@ratonmagico 6 жыл бұрын
This video is gold. Best explanation on modules and packages I've found in KZbin.
@HtorneDK
@HtorneDK 3 жыл бұрын
what an EXCELLENT video - this content is beyond any other tutorials on the web. omg this is good. Instant subscribe. Thanks
@MoistKing
@MoistKing 4 жыл бұрын
Thankyou for the great lecture! Love the "Banana" examples.
@AhmedAli-dz1hy
@AhmedAli-dz1hy 4 жыл бұрын
He is full of information. Better than professors
@dbmaster46446
@dbmaster46446 2 жыл бұрын
is following code the right way to use __init__ ? im still not sure how i should construct packages for module in os.listdir(os.path.dirname(__file__)): if module.startswith("__"): continue name = "{}.{}".format(__name__,module) if not module.endswith('.py') else "{}.{}".format(__name__,module[:-3]) __import__( name) del module
@damiantgordon
@damiantgordon 2 жыл бұрын
Perfect
@dbmaster46446
@dbmaster46446 2 жыл бұрын
@@damiantgordon excelent, thank you
@EasyLanguageCoach
@EasyLanguageCoach 5 жыл бұрын
Very well done. A good explanation of it. Thank you very much.
@feniordi
@feniordi 2 жыл бұрын
Simple explenation and good examples, thanks for the tutorial!
@cybervigilante
@cybervigilante 6 жыл бұрын
Wow, that cross-importing is cool. And it doesn't even have to be a class. I tried it on a simple function.
@AhmedAli-dz1hy
@AhmedAli-dz1hy 4 жыл бұрын
That is great. Like these slides and like your easy way of explanation
@scienceblossom6197
@scienceblossom6197 5 жыл бұрын
What if we want to import more than a module from a sub-directory? E.g. what if we want to import all the methods in a module in a subdirectory(e.g. ./childDir1/module ---> contains 10 methods)
@damiantgordon
@damiantgordon 5 жыл бұрын
With new Python this should work >>> from import *
@haopeiyang3443
@haopeiyang3443 5 жыл бұрын
Thank you for this video Mr. Gordon. The content is solid.
@yomajo
@yomajo 4 жыл бұрын
Say near the Maths, there's Biology folder, which has Calculations.py. How does one import Theorem.py into it? [...] |---Maths |--- --- __init.py |--- --- Theorem.py |---Biology |--- --- __init.py |--- --- Calculations.py
@Brandon-hb7tx
@Brandon-hb7tx 4 жыл бұрын
yomajo from Drawing.Maths import Theorem I would think
@nkosikhonampungose1500
@nkosikhonampungose1500 Ай бұрын
2024, still Gold🎉
@danibaba7058
@danibaba7058 5 жыл бұрын
How do i import a file but not run it?Just so i can use the variables??
@damiantgordon
@damiantgordon 5 жыл бұрын
Are they in a class in the file?
@danibaba7058
@danibaba7058 5 жыл бұрын
@@damiantgordon what do you mean?
@danibaba7058
@danibaba7058 5 жыл бұрын
@@damiantgordon This is first: import sys def Register(): choice = input("Would you like to register? Type yes or no. ") if choice == "yes": secured = open("login.txt" ,"w") Username = input("Username: ") secured.write(Username) Password = input("Password: ") secured.write(Password) secured.close() elif choice == "no": cond = False else: print("Please choose between Yes or No") Register() Register() sys.exit()
@danibaba7058
@danibaba7058 5 жыл бұрын
@@damiantgordon This is second : def Login(): question = input("Would you like to login? Type yes or no. ") if question == "yes": user = input("Username: ") passw = input("Password: ") secured.open("login.txt","r") secured.read(Username) secured.read(Password) if Username == user and Password == passw: print("Login successful") else: ex_or_res = input("Username/Password incorrect! Please try again or exit To try again type restart To exit type exit") if ex_or_res == "restart": Login() elif ex_or_res == "exit": sys.exit() else: sys.exit() if question == "no": sys.exit() Login()
@danibaba7058
@danibaba7058 5 жыл бұрын
@@damiantgordon I want to get input that is saved in a file login.txt in the module register and then read it in module login.So obviously i want to run module 1 but by running module 1 not by importing it to module2(if that makes sense).And then read the input from module 1 but in module 2.
@سفيانقريميدة
@سفيانقريميدة 4 жыл бұрын
Excellent explanation, thank you very much
@ettercap5384
@ettercap5384 6 жыл бұрын
How do I import the .py that is in the main folder and not in the subdirectory?
@damiantgordon
@damiantgordon 6 жыл бұрын
Just say "Import FileName"
@djamelfertas
@djamelfertas 4 жыл бұрын
Wow that's such an amazing explanation, Thank you Sir
@ProfessionalTycoons
@ProfessionalTycoons 6 жыл бұрын
I use this all the time, but never knew whats going on behind the scene lol
@beratakuzum8381
@beratakuzum8381 6 жыл бұрын
Amazing and detailed tutorial. Thank you so much!
@Adks007
@Adks007 5 жыл бұрын
Very nice video. Respect from United states
@dileepaozi2352
@dileepaozi2352 2 жыл бұрын
Wow nicely explained... can you do a video like this about distribution of python program to users, things like setup.py, python egg, pyInstaller.
@Mortum_Rex
@Mortum_Rex 6 жыл бұрын
Did anyone else keep thinking Damian was holding a cane the whole time in his remote hand? He'd look pretty badass with a cane I reckon. Anyway, brilliant lecture! Thank you, sir.
@dishonmwabashfano3627
@dishonmwabashfano3627 3 жыл бұрын
Thanks a lot. You are the best.
@niyagentleman8143
@niyagentleman8143 3 жыл бұрын
x-llent explanations! thanks so much for this tutorial! ^^
@likysquad
@likysquad 3 жыл бұрын
Geez, this is annoying, I can't compile my payload now because I've been using sys this whole time to duct tape the issue. My .py code is scattered all throughout my computer in different folders. Now I see I got a lot of learning to do. Thanks for the lecture.
@PwrTrumper
@PwrTrumper 4 жыл бұрын
great video, fantastic explanation. I still think this whole __init__ idea is an unintuitive design choice in python.
@sfcoawol6273
@sfcoawol6273 4 жыл бұрын
Thanks for this lecture! I've been trying to import code from other files but I was having issues with referenceing variables from outside the code snippet into the code. Most guides are way to basic to explain this
@Pedritox0953
@Pedritox0953 Жыл бұрын
Great video!
@shivamchaudhary470
@shivamchaudhary470 7 жыл бұрын
thank you sir
@seghairtarek4629
@seghairtarek4629 5 жыл бұрын
the best video ever thank you... you helped me a lot ^_^
@mikerihm
@mikerihm 6 жыл бұрын
This is fantastic
@PihFrags
@PihFrags 2 жыл бұрын
Very nice presentation Thank you for great content. One thing i noticed though was that you used uppercase names for packages. PEP 8 says points that lowercase should be used 😉But still. Structure and code was readable so still A+ for presentation
@richiekho1159
@richiekho1159 3 жыл бұрын
It is well explained, just that the sound need to be improveed
@motherofako
@motherofako 6 жыл бұрын
Wow sir , you are brilliant!
6 жыл бұрын
clean explanation.
@MadhuExplorer
@MadhuExplorer 7 жыл бұрын
Nicely explained...
@omphemetsemafoko830
@omphemetsemafoko830 3 жыл бұрын
Thank you.
@dontspeakitdoit
@dontspeakitdoit 2 жыл бұрын
11:58
@deeproy7292
@deeproy7292 7 жыл бұрын
You have helped a lot
@BS-eu9do
@BS-eu9do 4 жыл бұрын
Thank a lot
@kitcat2449
@kitcat2449 2 жыл бұрын
💕
@kitcat2449
@kitcat2449 2 жыл бұрын
I love learning python after languages like c++ and java haha, less work
@FERNAND0_MEDElR0S
@FERNAND0_MEDElR0S 7 жыл бұрын
Very good! Tks
Python Modules for Beginners
18:03
Dave Gray
Рет қаралды 12 М.
Python Modules and Packages - A Brief Introduction
13:51
Kris Jordan
Рет қаралды 15 М.
VIP ACCESS
00:47
Natan por Aí
Рет қаралды 30 МЛН
Chain Game Strong ⛓️
00:21
Anwar Jibawi
Рет қаралды 41 МЛН
This Is Why Python Data Classes Are Awesome
22:19
ArjanCodes
Рет қаралды 821 М.
Intermediate Python Tutorial: How to Use the __init__.py File
6:22
Eric O Meehan
Рет қаралды 146 М.
Python dataclasses will save you HOURS, also featuring attrs
8:50
Transforming Code into Beautiful, Idiomatic Python
48:51
Next Day Video
Рет қаралды 1 МЛН
Python Object Oriented Programming (OOP) - For Beginners
53:06
Tech With Tim
Рет қаралды 3,5 МЛН
Python Tutorial - Learn to write a command line interface program
29:35
Python Packaging from Init to Deploy
36:09
Next Day Video
Рет қаралды 126 М.
VIP ACCESS
00:47
Natan por Aí
Рет қаралды 30 МЛН