Python 3 Programming Tutorial - Making Modules

preview_player
Показать описание
In this video, we break down modules a bit more, and learn how to make our own. This is probably the easiest way to learn about how modules work and how we can use them in the future to aid our programs, or even work in groups and teams.

Bitcoin donations: 1GV7srgR4NJx4vrk7avCmmVQQrqmv87ty6
Рекомендации по теме
Комментарии
Автор

Your tutorials are really quick and can be watched anytime! Thank you so much!

RamisaAnjum
Автор

+Luke Paul ... for some reason I cannot respond to your comment directly, but... Most setup.py commands really are just sending the script to your site-packages, so you can indeed actually just download the module and do it yourself. A lot of modules have folders full of various scripts, which are full of functions, but you can usually just download the source and move the whole thing yourself. Great question!

sentdex
Автор

when i import one created module
from same directory in main program...
initially the module program is running??
why??

bmnone
Автор

wow, thanks so much, i had no idea were to save the file and though there was only one place you colud save them, this was a very helpful tutorial.

saulrathbonebochis
Автор

This series of videos is amazing - concise, and easy to follow. Thank you. This one is really useful: where to put your commonly used modules, so that you don't need to take a copy every time you use them - fantastic. BTW, for Mac users, the following Terminal command tells you where your site-packages directory lives: python3 -m site --user-site (it works on my MacBook Air, anyway).

petewhittet
Автор

Hi,
Thank you for your video. I do have a question. I am a beginner in python.
My problem is the following:
I have a main.py python script in somewhere in my machine.
It uses other.py which is located in a sub folder (so the same path + the subfolder).
Do you know how I can import this one? I could not find the information on the internet.
Thanks.

jonathanpepin
Автор

Greetings,

When I use the standard python shell, adding the script to site-packages works fine when typing:

IMPORT examplemod


However, if I use another editor I have to type:

FROM site-packages IMPORT examplemod

Is there a way around not having to type the keyword FROM and do it how you teach in the video with another editor?
Caps are for keywords. Thank you.

GonTheTube
Автор

I built a module to keep the code in my main more brief and getting too messy. In the module, I have to import some other modules like openpyxl to make it do what I want. Do I import openpyxl at the very top (outside of the def statement) or does it have to be inside each block of code after the def statement? I assume it has to go inside each one of def block that I create in the module.

fredhogan
Автор

I've been trying to get something like this to work, I wanted my Python to be able to import functions and such from another folder rather than having a bunch of floating files, and have folders of .py files that are grouped by together in different locations. However, this seems like something that's not typical to setup, because you keep getting module errors like this, even if you feed Python a file path.

Gakusangi
Автор

Traceback (most recent call last):
File "C:/Python34/Scripts/chess.py", line 1, in <module>
import chess
File "C:/Python34/Scripts\chess.py", line 6, in <module>
chess.move_check()
AttributeError: 'module' object has no attribute 'move_check'

I have checked the spelling so what do I do?

britishsoldier
Автор

thank you so much, I'm going through a self-study coding summer course which had horrible instructions following the usage and set up of modules.

superhessu
Автор

it works for me without having to make mod, is that okay?

programmer
Автор

I'm able to understand the tutorials easily and clearly, but there is one thing which I don't understand. Why has this guy got only 523k subscribers? Jeez! He deserves a lot more

nitishkhanna
Автор

can you please tell us how to do this module thing for jupyter?

sneha
Автор

My module is inside the site-package folder along with the default modules that work when I call them but when I try to import mine the module cant be found...

StewieStew
Автор

Hi this is Awsome, I have a question for creating modules, How the Import is working ? and what is main role of __init__.py while creating third part packages?

silence_coder
Автор

How to do the same thing done in this video in Android i.e. by using Pydroid 3

Swaroopsky
Автор

Can you show how to connect MySQL with python

SanjayKumar-espv
Автор

I am not getting from examplemod.ex ('test') thing it's again giving me error maye I know what kind of error i am making

voicebox
Автор

where do we use if '__main__'==main ?

rony