How To Create Your Own Modules In Python (Modularization)

แชร์
ฝัง
  • เผยแพร่เมื่อ 17 ต.ค. 2024
  • Modularizing your code is a pretty easy tool to help clear out your code a bit, and make it much more readable. In this video I show you how to define a few functions, save them in a separate file, and import that file as a module in a separate code, while still being able to access those functions.
    To keep the module in ipynb:
    jupyter-noteboo...

ความคิดเห็น • 108

  • @subhosmito
    @subhosmito 4 ปีที่แล้ว +4

    Dear Andrew, Your video is a very good guide and you deserve a big thank you. But a word of caution to newbies; whenever you are trying to make these changes either refresh the JN or restart it. Don't forget to save your data first!

  • @eliorbilow8797
    @eliorbilow8797 3 ปีที่แล้ว +1

    I'm so used to you're comedic skits that I was surprised when I found this after googling for help. Awesome video. Thanks!

  • @Swagsy
    @Swagsy 4 ปีที่แล้ว

    I have a python script and the folder with a specific module but every time I run it, it can't import the module. Where do I have to put it for it to be able to find it?

  • @connectingthedots5987
    @connectingthedots5987 3 ปีที่แล้ว

    hey you just helped me understand how to create my own modules from a function. life is easy with guys like you. new python guy here

  • @ruifonseca6147
    @ruifonseca6147 4 ปีที่แล้ว

    Hello. I am a newbie in programming world. I was stuck not being able to create and use modules in Jupyter Notebook. Thanks to you I can jump to other subjects in my studies of Python. Thank you a lot!

  • @bendalfavero6505
    @bendalfavero6505 5 ปีที่แล้ว +23

    Something I heard over and over in my programming for engineers class: "I don't understand why it won't work. It worked the other 50 times I copied and pasted it!"

  • @2sakuraa2
    @2sakuraa2 4 ปีที่แล้ว +10

    More than helpful! less than 10 minutes and you made it so clear! thank you so much for sharing

  • @estefaniatapia1546
    @estefaniatapia1546 4 ปีที่แล้ว +7

    You do not know how I've looked for this, thank you so much!!

  • @FaizYah
    @FaizYah 4 ปีที่แล้ว +1

    broooooooo thank you so much!! Ive been looking for this for hours and you just solved my problem in a few minutes!!

  • @josephnnodim8244
    @josephnnodim8244 3 ปีที่แล้ว

    This is amazing, especially where you stated that the file has to be converted to .py format. Thank you!

  • @SirSteveFury
    @SirSteveFury 2 ปีที่แล้ว

    Thanks for the video. I wonder why folks can't explain things simply using simple basic code that doesn't involve a simple basic beginner program like passing a couple integer values in and out of a module. Instead everyone puts a very complicated and convoluted code designed for advanced programmers to already recognize. Creating a simple module with just a def that adds a & b then passes it back is so much easier to understand.

  • @Swaroop2sky
    @Swaroop2sky 4 ปีที่แล้ว +3

    Is there any way to do the exactly same thing in Mobile, by using " Pydroid " ?

  • @drover7476
    @drover7476 4 ปีที่แล้ว +1

    almost spunked when i saw that the goat dotson has programming videos, so eigenvaluable

  • @pipertripp
    @pipertripp 6 ปีที่แล้ว

    Cool to see this done in jupyter. I'm a new to python, but have been coding for years, so the concepts are all very familiar. Just learning the python specifics.

    • @AndrewDotsonvideos
      @AndrewDotsonvideos  6 ปีที่แล้ว

      Yeah It reminds me of just using structs or classes in C++, but a bit easier in my opinion!

  • @diankadroz
    @diankadroz 3 ปีที่แล้ว +1

    Glorious Andrew,
    you are the first programming youtuber I have watched and actually learned something.
    You sir, may be why I finish this programming project with pride and honor.
    _You_ deserve a medal!
    Thank you for existing, now have a glorious day you fine fellow!
    Sincerely,
    an indebted viewer
    (hopefully my subscription and like is enough payment)

  • @ABHINAB13
    @ABHINAB13 4 ปีที่แล้ว

    Thanks Man, for the past 1 hour I have been trying to figure this out.

  • @nazmulhasannahid9010
    @nazmulhasannahid9010 4 ปีที่แล้ว +2

    Thanks, man. I was looking for this and you explained perfectly and exactly what I was looking for.

  • @richardaversa7128
    @richardaversa7128 ปีที่แล้ว

    This video was so helpful and saved a lot of time. Thanks!

  • @sergioramos3437
    @sergioramos3437 3 ปีที่แล้ว

    This was the easiest way I've seen of doing this! Thank you

  • @Makabaril
    @Makabaril 6 ปีที่แล้ว +1

    You mentioned possibly Skype tutoring for physics & math in an older video; what do you think the costs would look like?

  • @PRASHANTKUMAR-pg4vl
    @PRASHANTKUMAR-pg4vl 4 ปีที่แล้ว

    Thank you for such an awesome explaining video on Modularization of code

  • @kimsourtat601
    @kimsourtat601 4 ปีที่แล้ว

    for those who using anacoda
    1. run anacoda prompt : search bar , type anacoda --> run administrators
    2. run : activateenvironment-name
    3. run: where python
    4. now you know the place that you can paste you r code (.py)
    5. go to python location that definte in step 3
    6. the go to : lib>site-packages and paste your code ( plot_classifier.py ).Now you can run python with your new library ( Ex: from plot_classifier import *)

  • @smoothumut
    @smoothumut 3 ปีที่แล้ว

    I gave you thumbs up in the first 8 seconds : ) for a nice, sincere start

  • @mikecmw8492
    @mikecmw8492 5 ปีที่แล้ว +13

    Is there a way to install these python modules globally?

    • @sebastiangarciaacosta5468
      @sebastiangarciaacosta5468 3 ปีที่แล้ว

      I think that is more reliable creating your module (adding a setup.py file at the same level of the module) rather than put it manually in site-packages.

  • @sashacurcic1719
    @sashacurcic1719 4 ปีที่แล้ว

    I'm really enjoying the merch you have shown here.

  • @raghusrinivasamurthy6191
    @raghusrinivasamurthy6191 4 ปีที่แล้ว +2

    I was searching for this so much!!!!! Thanksssssss!!!!!

  • @DrIlyas-sq7pz
    @DrIlyas-sq7pz 5 ปีที่แล้ว +1

    Thank you sir. Can we use more than one file for longer code in a more simple way, like we do in C++ and in latex?

  • @preksha5796
    @preksha5796 3 ปีที่แล้ว

    Great Video on Python Module !!! Thank you

  • @sonalishinde5104
    @sonalishinde5104 4 ปีที่แล้ว

    hey.....I found it soo useful...thnx for this video...thnx for being there for learners like me...

  • @priyadoesdatascience5141
    @priyadoesdatascience5141 3 ปีที่แล้ว

    thanks for the video, but the issue is that if I have a different jupyter file in another directory, it is not going to import the module. It seems like I need to move the module file all the time with new folder

  • @guynes2013
    @guynes2013 5 ปีที่แล้ว

    Thank you so much! I'm starting to learning coding with python and I've been trying to figure out how to do exactly this.

  • @mauricestraube3308
    @mauricestraube3308 5 ปีที่แล้ว +1

    Thx for the nice video!
    Do you know how to adjust the uploaded python function within the notebook and then be able to access the newly added function?
    I encountered issues here not being able add new functions, even if I deleted and reuploaded the .py-file.

  • @MikeD-qx1kr
    @MikeD-qx1kr 4 ปีที่แล้ว +5

    This was great! So clear. How about a video that explains the same thing but if you work from PyCharm?

  • @abanerjee3704
    @abanerjee3704 4 ปีที่แล้ว

    great work brother....keep it up

  • @sergioramos3437
    @sergioramos3437 3 ปีที่แล้ว

    Are .py files readable in a text editor? In case I forget what functions I put in there or something

    • @t.t.cooperphd5389
      @t.t.cooperphd5389 3 ปีที่แล้ว

      I like Atom for a .py IDE when I am not using jupyter, integrates with Github well too.

  • @MpumeleloSbusiso
    @MpumeleloSbusiso 6 หลายเดือนก่อน

    Bro knows how to explain like brocode my guy he is leggit,youtube aint paying him enough

  • @thebigoeuph
    @thebigoeuph 6 ปีที่แล้ว

    I noticed that you have a copy of Jackson's Electrodynamics. I'm actually taking E&M 1 this fall and wanted to know if you'd recommend Jackson or read Griffiths all the way?

    • @AndrewDotsonvideos
      @AndrewDotsonvideos  6 ปีที่แล้ว +1

      If you're talking about undergrad, definitely griffiths. Jackson will fill you with the urge to punt a squirrel.

  • @CurrentElectrical
    @CurrentElectrical 3 ปีที่แล้ว

    This video is going to break the internet- as the template of getting to the point and a fantastic explanation- even for me, the FNG to coding. Thank you. and Sub'd

  • @dylanhaymore608
    @dylanhaymore608 6 ปีที่แล้ว

    jagexcache? Hmm... Lol. Love the content btw. Your daily upload pace is quite impressive!

  • @imadjabir1678
    @imadjabir1678 3 ปีที่แล้ว

    Andrew, could you please tell me how to upload the module my_math as .ipynb instead of .py and then import it to another .ipynb file.

  • @channamsettyvenkataramaiah4625
    @channamsettyvenkataramaiah4625 4 ปีที่แล้ว

    Excellent teaching dude!

  • @sergionunez5964
    @sergionunez5964 2 ปีที่แล้ว

    This was a very helpful video. Thank you so much for do it!

  • @omarpasha9855
    @omarpasha9855 2 ปีที่แล้ว

    I did my first quick overview! Now, I'll start my coding. But, I'll create the module by using text file.

  • @jaysimhasindhanoor
    @jaysimhasindhanoor 5 ปีที่แล้ว

    Finally it worked for me , i was searching for this. Thanks a lot :) :)

  • @dostarora97
    @dostarora97 6 ปีที่แล้ว +1

    How did you learn Python? What are some resources which explain by doing example programs

    • @AndrewDotsonvideos
      @AndrewDotsonvideos  6 ปีที่แล้ว +2

      I learned by just trying to finish certain projects. The Clever Programmer is great for very intro-level python!

    • @MADARAISEPIC1
      @MADARAISEPIC1 6 ปีที่แล้ว

      Get the solo learn app

    • @MADARAISEPIC1
      @MADARAISEPIC1 6 ปีที่แล้ว

      And here's a good introduction: th-cam.com/video/Z1Yd7upQsXY/w-d-xo.html

  • @satyakikc9152
    @satyakikc9152 4 ปีที่แล้ว

    Great video mate !! helped me a lot..

  • @JamFilledDonut
    @JamFilledDonut 6 ปีที่แล้ว

    Question: There's a Quantum Field Theory course available for my final year. Really want to study it. Will it be impossible?

  • @parteekmandhan7522
    @parteekmandhan7522 6 ปีที่แล้ว

    Hi, I am in high school in Australia and I really love physics. Yours videos are very inspiring and insightful. I want to make a research paper in physics in the area of optics. Do you have any experience in optics? If so, could you please suggest me a subject in optics that hasn’t been properly developed yet?

  • @ebbydavid9536
    @ebbydavid9536 ปีที่แล้ว

    why is it when i download asking me the file can harm your computer?

  • @Popcorn_and_funny_moments
    @Popcorn_and_funny_moments 2 ปีที่แล้ว

    would you do more examples please, thank you , you're doing good work

  • @rryann088
    @rryann088 3 ปีที่แล้ว

    Thanks a lot! It was super helpful !

  • @sergioramos3437
    @sergioramos3437 3 ปีที่แล้ว

    Or is there a built-in way to ask python what functions are in there? Or a way you can build it in yourself?

  • @natetolbert3671
    @natetolbert3671 2 ปีที่แล้ว

    ~@4:35 CTRL + x is your friend... good vid

  • @Patriciovaldivieso
    @Patriciovaldivieso 4 ปีที่แล้ว

    Very helpful, thanks!

  • @hiraamena3358
    @hiraamena3358 5 ปีที่แล้ว

    really,it's a helpful for create own module .Thanks

  • @niveditakanrar8599
    @niveditakanrar8599 4 ปีที่แล้ว

    Thank you so much for explaining this!

  • @mdabdulwahab1040
    @mdabdulwahab1040 4 ปีที่แล้ว

    yah.. it was really helpful.thanks buddy

  • @williamusuga4491
    @williamusuga4491 4 ปีที่แล้ว

    Excellent explication

  • @handsonrosanamarube1724
    @handsonrosanamarube1724 5 ปีที่แล้ว

    Plz can you send mi the module you have I need to use it to run something here in python program

  • @PankajBhandari
    @PankajBhandari 4 ปีที่แล้ว

    you are genius

  • @safecomiguel
    @safecomiguel 4 ปีที่แล้ว

    This was great, Thank you!

  • @Live4Ibanez
    @Live4Ibanez 4 ปีที่แล้ว

    Thanks. I'm putting together a library to generate pspice netlists

  • @vishalsadawarte1783
    @vishalsadawarte1783 4 ปีที่แล้ว

    thanks for your help man..

  • @gyanaranjan6526
    @gyanaranjan6526 2 ปีที่แล้ว +1

    I got this 💖

  • @VivekSharma-bl7cs
    @VivekSharma-bl7cs 5 ปีที่แล้ว

    thanks brother it is helpful video

  • @maricsakyi5050
    @maricsakyi5050 3 ปีที่แล้ว +1

    very cool.

  • @nguaial8490
    @nguaial8490 5 ปีที่แล้ว

    I am getting No module named error.

  • @jai_sree_ram4084
    @jai_sree_ram4084 8 หลายเดือนก่อน

    thank you so much sir

  • @FRANKWHITE1996
    @FRANKWHITE1996 ปีที่แล้ว

    thanks for sharing :)

  • @ShantanuPramanikSRSshaan
    @ShantanuPramanikSRSshaan 3 ปีที่แล้ว

    Try looking into the camera lens and not the lcd display

  • @jeancolombel4618
    @jeancolombel4618 4 ปีที่แล้ว

    Thanks a lot !

  • @soumyadrip
    @soumyadrip 4 ปีที่แล้ว

    It was helpful thanks💖

  • @robinpage2730
    @robinpage2730 2 ปีที่แล้ว

    Dotson! Dotson! We've got Dotson, here!

  • @nikolabadjevic8189
    @nikolabadjevic8189 6 ปีที่แล้ว

    Thanks. Really helpful :)

  • @sumairayousuf9431
    @sumairayousuf9431 4 ปีที่แล้ว

    Please create a project on how to run a machine learning project of github on jupyter notebook

  • @fazilokuyanus3396
    @fazilokuyanus3396 5 ปีที่แล้ว

    you are God , I blieve in you!:D

  • @fulufheloramatha293
    @fulufheloramatha293 ปีที่แล้ว

    Thanks bro 🙏

  • @programmingjourney6773
    @programmingjourney6773 3 ปีที่แล้ว

    thanks a ton!!!!

  • @nishasilori4222
    @nishasilori4222 3 ปีที่แล้ว

    Thanku so much 😊

  • @Experts_top_5
    @Experts_top_5 4 ปีที่แล้ว

    thanks man,

  • @kylesanchez8022
    @kylesanchez8022 4 ปีที่แล้ว

    Anyone getting a "null" is not defined error??

  • @cicciobombo7496
    @cicciobombo7496 6 ปีที่แล้ว

    Lol, do you actully use McAFee? Nice video!

  • @sanketpadwal7298
    @sanketpadwal7298 4 ปีที่แล้ว

    thanks mate

  • @kitawayele6044
    @kitawayele6044 4 ปีที่แล้ว

    thank you that is great

  • @123hgggmllvcc
    @123hgggmllvcc 5 ปีที่แล้ว

    nice video, but the modularization part actually begins at 4:33

  • @gangsterj73
    @gangsterj73 6 ปีที่แล้ว +2

    Where's today's video update ?

  • @ruixue6955
    @ruixue6955 4 ปีที่แล้ว

    4:28
    4:57 name of the module

  • @Magda-jm7mh
    @Magda-jm7mh 3 ปีที่แล้ว

    dzieki dziala

  • @andrewfischer-garbutt2867
    @andrewfischer-garbutt2867 4 ปีที่แล้ว

    Watching you write vec1 twice was painful

  • @escapefelicity2913
    @escapefelicity2913 3 ปีที่แล้ว

    lose the hat

  • @dylanhaymore608
    @dylanhaymore608 6 ปีที่แล้ว

    jagexcache? Hmm... Lol. Love the content btw. Your daily upload pace is quite impressive!

  • @jesuisravi
    @jesuisravi 2 ปีที่แล้ว

    very cool

  • @CharanTeja-cm8ug
    @CharanTeja-cm8ug 5 ปีที่แล้ว

    Thank you boss

  • @zulfiqarali-zq1rg
    @zulfiqarali-zq1rg 5 ปีที่แล้ว

    thanku soo much sir