Thank you for explaining modules so clearly. I starting programming in FORTRAN IV in the 80s, Python has me excited about programming again.
@RaynerDaCruz4 жыл бұрын
@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()?
@wiliextreme2 жыл бұрын
thanks for this great video, coming from nodejs I found it pretty confusing how python imports work but now I get it
@ryansossou6463 жыл бұрын
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
@ratonmagico6 жыл бұрын
This video is gold. Best explanation on modules and packages I've found in KZbin.
@HtorneDK3 жыл бұрын
what an EXCELLENT video - this content is beyond any other tutorials on the web. omg this is good. Instant subscribe. Thanks
@MoistKing4 жыл бұрын
Thankyou for the great lecture! Love the "Banana" examples.
@AhmedAli-dz1hy4 жыл бұрын
He is full of information. Better than professors
@dbmaster464462 жыл бұрын
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
@damiantgordon2 жыл бұрын
Perfect
@dbmaster464462 жыл бұрын
@@damiantgordon excelent, thank you
@EasyLanguageCoach5 жыл бұрын
Very well done. A good explanation of it. Thank you very much.
@feniordi2 жыл бұрын
Simple explenation and good examples, thanks for the tutorial!
@cybervigilante6 жыл бұрын
Wow, that cross-importing is cool. And it doesn't even have to be a class. I tried it on a simple function.
@AhmedAli-dz1hy4 жыл бұрын
That is great. Like these slides and like your easy way of explanation
@scienceblossom61975 жыл бұрын
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)
@damiantgordon5 жыл бұрын
With new Python this should work >>> from import *
@haopeiyang34435 жыл бұрын
Thank you for this video Mr. Gordon. The content is solid.
@yomajo4 жыл бұрын
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-hb7tx4 жыл бұрын
yomajo from Drawing.Maths import Theorem I would think
@nkosikhonampungose1500Ай бұрын
2024, still Gold🎉
@danibaba70585 жыл бұрын
How do i import a file but not run it?Just so i can use the variables??
@damiantgordon5 жыл бұрын
Are they in a class in the file?
@danibaba70585 жыл бұрын
@@damiantgordon what do you mean?
@danibaba70585 жыл бұрын
@@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()
@danibaba70585 жыл бұрын
@@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()
@danibaba70585 жыл бұрын
@@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
@ettercap53846 жыл бұрын
How do I import the .py that is in the main folder and not in the subdirectory?
@damiantgordon6 жыл бұрын
Just say "Import FileName"
@djamelfertas4 жыл бұрын
Wow that's such an amazing explanation, Thank you Sir
@ProfessionalTycoons6 жыл бұрын
I use this all the time, but never knew whats going on behind the scene lol
@beratakuzum83816 жыл бұрын
Amazing and detailed tutorial. Thank you so much!
@Adks0075 жыл бұрын
Very nice video. Respect from United states
@dileepaozi23522 жыл бұрын
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_Rex6 жыл бұрын
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.
@dishonmwabashfano36273 жыл бұрын
Thanks a lot. You are the best.
@niyagentleman81433 жыл бұрын
x-llent explanations! thanks so much for this tutorial! ^^
@likysquad3 жыл бұрын
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.
@PwrTrumper4 жыл бұрын
great video, fantastic explanation. I still think this whole __init__ idea is an unintuitive design choice in python.
@sfcoawol62734 жыл бұрын
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 Жыл бұрын
Great video!
@shivamchaudhary4707 жыл бұрын
thank you sir
@seghairtarek46295 жыл бұрын
the best video ever thank you... you helped me a lot ^_^
@mikerihm6 жыл бұрын
This is fantastic
@PihFrags2 жыл бұрын
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
@richiekho11593 жыл бұрын
It is well explained, just that the sound need to be improveed
@motherofako6 жыл бұрын
Wow sir , you are brilliant!
6 жыл бұрын
clean explanation.
@MadhuExplorer7 жыл бұрын
Nicely explained...
@omphemetsemafoko8303 жыл бұрын
Thank you.
@dontspeakitdoit2 жыл бұрын
11:58
@deeproy72927 жыл бұрын
You have helped a lot
@BS-eu9do4 жыл бұрын
Thank a lot
@kitcat24492 жыл бұрын
💕
@kitcat24492 жыл бұрын
I love learning python after languages like c++ and java haha, less work