René's URL Explorer Experiment


Title: Creating Packages (Video) – Real Python

Open Graph Title: Creating Packages – Real Python

Description: Let’s create a package structure. I’m here in my terminal, but you can totally create those files in your Windows Explorer or your Mac Finder or on your Linux file application app, which name I don’t know, but you can also follow me along with the…

Open Graph Description: Let’s create a package structure. I’m here in my terminal, but you can totally create those files in your Windows Explorer or your Mac Finder or on your Linux file application app, which name I don’t know, but you can also follow me along with the…

Opengraph URL: https://realpython.com/lessons/creating-python-packages/

X: @realpython

direct link

Domain: realpython.com


Hey, it has json ld scripts:
  {
    "@context": "https://schema.org",
    "@type": "VideoObject",
    "name": "Creating Packages",
    "description": "Let’s create a package structure. I’m here in my terminal, but you can totally create those files in your Windows Explorer or your Mac Finder or on your Linux file application app, which name I don’t know, but you can also follow me along with the…",
    "thumbnailUrl": ["https://files.realpython.com/media/Modules-and-Packages_Watermarked.bc38abc24435.jpg"],
    "uploadDate": "2023-11-14T14:00:00+00:00",
    "duration": "PT3M21S",
    
    "potentialAction": {
      "@type": "SeekToAction",
      "target": "https://realpython.com/lessons/creating-python-packages/#t={seek_to_second_number}",
      "startOffset-input": "required name=seek_to_second_number"
    }
  }
  

authorReal Python
theme-color#18354c
color-schemelight dark
twitter:cardsummary_large_image
twitter:imagehttps://files.realpython.com/media/Modules-and-Packages_Watermarked.bc38abc24435.jpg
og:imagehttps://files.realpython.com/media/Modules-and-Packages_Watermarked.bc38abc24435.jpg
twitter:creator@realpython
og:typevideo.episode
og:site_nameReal Python
apple-mobile-web-app-titleReal Python

Links:

https://realpython.com/
Start Herehttps://realpython.com/start-here/
Learn Python https://realpython.com/lessons/creating-python-packages/
Your Learning Plan →Your personalized Python learning planhttps://realpython.com/account/learning-plan/
Python Tutorials →In-depth articles and video courseshttps://realpython.com/search?kind=article&kind=course&order=newest&_from=nav_library
Learning Paths →Guided study plans for accelerated learninghttps://realpython.com/learning-paths/
Quizzes & Exercises →Check your learning progresshttps://realpython.com/search?kind=exercise&kind=quiz&_from=nav_library
Browse Topics →Focus on a specific area or skill levelhttps://realpython.com/tutorials/all/
Reference →Concise definitions for common Python termshttps://realpython.com/ref/
Mentor AI →NewYour personal Python mentorhttps://realpython.com/mentor/
Office Hours →Live Q&A calls with Python expertshttps://realpython.com/office-hours/
Community Chat →Learn with other Pythonistashttps://realpython.com/community/
Live Courses →Live, instructor-led Python courseshttps://realpython.com/live/
Books →Round out your knowledge and learn offlinehttps://realpython.com/products/books/
Podcast →Hear what’s new in the world of Pythonhttps://realpython.com/podcasts/rpp/
Unlock All Content and Become a Python Expert →Get unlimited access to all Real Python has to offerhttps://realpython.com/account/join/?from=navbar_learn
Unlock All Content →Become a Python Experthttps://realpython.com/account/join/?from=navbar_learn
More https://realpython.com/lessons/creating-python-packages/
Learner Storieshttps://realpython.com/learner-stories/
Python Newsletterhttps://realpython.com/newsletter/
Python Job Boardhttps://www.pythonjobshq.com
Meet the Teamhttps://realpython.com/team/
Become a Contributorhttps://realpython.com/jobs/
Searchhttps://realpython.com/search
https://realpython.com/search
Joinhttps://realpython.com/account/join/
Sign‑Inhttps://realpython.com/account/login/?intent=navbar&next=%2Flessons%2Fcreating-python-packages%2F
Unlock This Lessonhttps://realpython.com/account/join/?utm_source=rp_lesson&utm_content=python-basics-modules-packages
Unlock This Lessonhttps://realpython.com/account/join/?utm_source=rp_lesson&utm_content=python-basics-modules-packages
https://realpython.com/courses/python-basics-modules-packages/#team
Python Basics: Modules and Packageshttps://realpython.com/courses/python-basics-modules-packages/
Philipp Acsanyhttps://realpython.com/courses/python-basics-modules-packages/#team
Course Slides (.pdf)https://realpython.com/courses/python-basics-modules-packages/downloads/python-basics-modules-packages-slides/
Sample Code (.zip)https://realpython.com/courses/python-basics-modules-packages/downloads/python-basics-modules-packages-code/
Ask a Questionhttps://realpython.com/lessons/creating-python-packages/#discussion
https://realpython.com/feedback/survey/course/python-basics-modules-packages/liked/?from=lesson-title
https://realpython.com/feedback/survey/course/python-basics-modules-packages/disliked/?from=lesson-title
Contentshttps://realpython.com/lessons/creating-python-packages/#description
Transcripthttps://realpython.com/lessons/creating-python-packages/#transcript
Discussion (2)https://realpython.com/lessons/creating-python-packages/#discussion
00:00https://realpython.com/lessons/creating-python-packages/#t=0.745
Let’s create a package structure.https://realpython.com/lessons/creating-python-packages/#t=0.745
I’m here in my terminal,https://realpython.com/lessons/creating-python-packages/#t=2.537
but you can totally create those files in your Windows Explorer or yourhttps://realpython.com/lessons/creating-python-packages/#t=4.035
Mac Finder or on your Linux file applicationhttps://realpython.com/lessons/creating-python-packages/#t=8.955
app, which name I don’t know,https://realpython.com/lessons/creating-python-packages/#t=14.035
but you can also follow me along with the terminal.https://realpython.com/lessons/creating-python-packages/#t=16.075
00:20https://realpython.com/lessons/creating-python-packages/#t=20.855
Navigate to the desktop and create a folder namedhttps://realpython.com/lessons/creating-python-packages/#t=20.855
packages_example/.https://realpython.com/lessons/creating-python-packages/#t=25.925
Then navigate into this folder.https://realpython.com/lessons/creating-python-packages/#t=27.71
00:34https://realpython.com/lessons/creating-python-packages/#t=34.375
And in this folder, create another folder.https://realpython.com/lessons/creating-python-packages/#t=34.375
And this one,https://realpython.com/lessons/creating-python-packages/#t=37.106
you name mypackage/.https://realpython.com/lessons/creating-python-packages/#t=38.375
00:43https://realpython.com/lessons/creating-python-packages/#t=43.295
The packages_example folder is called the project folder,https://realpython.com/lessons/creating-python-packages/#t=43.295
or project root folder,https://realpython.com/lessons/creating-python-packages/#t=48.095
because it will contain all the files and folders in thehttps://realpython.com/lessons/creating-python-packages/#t=49.905
packages_example/ project.https://realpython.com/lessons/creating-python-packages/#t=53.395
00:55https://realpython.com/lessons/creating-python-packages/#t=55.135
The mypackage/ folder will eventually become a Python package.https://realpython.com/lessons/creating-python-packages/#t=55.135
It isn’t one right now because it doesn’t contain any modules.https://realpython.com/lessons/creating-python-packages/#t=59.495
So to change that, hop over to IDLE and create a new editor window.https://realpython.com/lessons/creating-python-packages/#t=63.455
01:10https://realpython.com/lessons/creating-python-packages/#t=70.005
As mentioned before, to make a folder a Python package,https://realpython.com/lessons/creating-python-packages/#t=70.005
you need to have a __init__ file in it.https://realpython.com/lessons/creating-python-packages/#t=73.125
So never forget to have __init__ in it.https://realpython.com/lessons/creating-python-packages/#t=75.925
01:20https://realpython.com/lessons/creating-python-packages/#t=80.192
Yeah,https://realpython.com/lessons/creating-python-packages/#t=80.192
and as mentioned before, also this file can be empty.https://realpython.com/lessons/creating-python-packages/#t=81.215
So without adding any content to it,https://realpython.com/lessons/creating-python-packages/#t=84.815
save a new file from your IDLE editor window ashttps://realpython.com/lessons/creating-python-packages/#t=87.665
__init__.pyhttps://realpython.com/lessons/creating-python-packages/#t=92.605
in the mypackage/ subfolder of your packages_example/ folderhttps://realpython.com/lessons/creating-python-packages/#t=95.615
01:44https://realpython.com/lessons/creating-python-packages/#t=104.355
Then open another window and add the following function:https://realpython.com/lessons/creating-python-packages/#t=104.355
def greet(name):https://realpython.com/lessons/creating-python-packages/#t=108.765
And then on the next line,https://realpython.com/lessons/creating-python-packages/#t=112.845
indented, print().https://realpython.com/lessons/creating-python-packages/#t=116.855
And then let’s do an f-string: f"Hello, {name}!" and the closing parentheses.https://realpython.com/lessons/creating-python-packages/#t=119.335
02:12https://realpython.com/lessons/creating-python-packages/#t=132.155
So there is a greet() function that takes name, and insidehttps://realpython.com/lessons/creating-python-packages/#t=132.155
greet(),https://realpython.com/lessons/creating-python-packages/#t=136.865
you call the print() function, and then you print a string, Hello, with thehttps://realpython.com/lessons/creating-python-packages/#t=137.435
name that was passed into the function.https://realpython.com/lessons/creating-python-packages/#t=142.295
02:25https://realpython.com/lessons/creating-python-packages/#t=145.435
Save this file as module1.pyhttps://realpython.com/lessons/creating-python-packages/#t=145.435
in the same folder as the __init__ file.https://realpython.com/lessons/creating-python-packages/#t=147.685
And to make the package complete,https://realpython.com/lessons/creating-python-packages/#t=153.305
create a new file in your IDLE editor with this code—https://realpython.com/lessons/creating-python-packages/#t=155.345
def depart():—which takes one parameter,https://realpython.com/lessons/creating-python-packages/#t=160.855
which is name.https://realpython.com/lessons/creating-python-packages/#t=163.725
02:45https://realpython.com/lessons/creating-python-packages/#t=165.514
And inside the function body, againhttps://realpython.com/lessons/creating-python-packages/#t=165.514
a print() function call.https://realpython.com/lessons/creating-python-packages/#t=168.575
And this time, you use an f-string saying goodbye,https://realpython.com/lessons/creating-python-packages/#t=169.835
and then in curly braces the name.https://realpython.com/lessons/creating-python-packages/#t=174.115
02:59https://realpython.com/lessons/creating-python-packages/#t=179.595
Just like before, you’ll save this file in the mypackage/ subfolder.https://realpython.com/lessons/creating-python-packages/#t=179.595
And you name this file module2.py,https://realpython.com/lessons/creating-python-packages/#t=183.185
03:11https://realpython.com/lessons/creating-python-packages/#t=191.055
and that’s a package.https://realpython.com/lessons/creating-python-packages/#t=191.055
With this structure, the files, and the code in place,https://realpython.com/lessons/creating-python-packages/#t=192.466
you are now ready to import and use these modules in another module.https://realpython.com/lessons/creating-python-packages/#t=196.375
Dec. 27, 2023https://realpython.com/lessons/creating-python-packages/#comment-2b560bd2-d32f-4f80-957a-dea037ea951d
Jan. 3, 2024https://realpython.com/lessons/creating-python-packages/#comment-cad1577a-9487-4a9c-bf6c-ecc7a89b0d4f
Useful Terminal Commandshttps://realpython.com/terminal-commands/
Using the Terminal on Windowshttps://realpython.com/courses/using-terminal-windows/
Your Python Coding Environment on Windows: Setup Guidehttps://realpython.com/python-coding-setup-windows/
Become a Memberhttps://realpython.com/account/join/
https://realpython.com/lessons/introducing-python-packages/
Overviewhttps://realpython.com/courses/python-basics-modules-packages/
https://realpython.com/lessons/working-with-packages/
Python Basics: Modules and Packages (Overview) 01:44 https://realpython.com/videos/modules-packages-overview/
Working With Modules 00:27 https://realpython.com/videos/working-with-python-modules/
Creating Modules 01:55 https://realpython.com/videos/creating-python-modules/
Calling an Imported Object 01:45 https://realpython.com/lessons/call-imported-object/
Understanding Namespaces 00:27 https://realpython.com/lessons/understanding-namespaces/
Accessing Objects From Inside a Module 01:02 https://realpython.com/lessons/accessing-module-objects/
Using Dot Notation for Imported Objects 00:54 https://realpython.com/lessons/dot-notation-imported-objects/
Adding Objects to a Namespace 01:29 https://realpython.com/lessons/adding-namespace-objects/
Breaking a Program Into Modules 00:45 https://realpython.com/lessons/break-program-into-modules/
Exercise: Import and Use a Module 08:00 https://realpython.com/lessons/exercise-import-use-module/
Exercise: Fix a Broken Import 08:00 https://realpython.com/lessons/exercise-fix-broken-import/
Renaming an Imported Module 02:42 https://realpython.com/lessons/rename-imported-module/
Importing Objects From a Module 03:20 https://realpython.com/lessons/import-module-objects/
Summarizing Import Statements 03:18 https://realpython.com/lessons/summarizing-import-statements/
Exercise: Import Specific Functions 08:00 https://realpython.com/lessons/exercise-import-specific-functions/
Taking Advantage of Namespaces 01:04 https://realpython.com/lessons/namespace-advantages/
Introducing Packages 01:16 https://realpython.com/lessons/introducing-python-packages/
Creating Packages 03:21 https://realpython.com/lessons/creating-python-packages/
Working With Packages 04:16 https://realpython.com/lessons/working-with-packages/
Summarizing Import Statements for Packages 01:40 https://realpython.com/lessons/package-import-statements/
Importing Modules From Subpackages 03:57 https://realpython.com/lessons/importing-modules-from-subpackages/
Exercise: Import From a Package 08:00 https://realpython.com/lessons/exercise-import-from-package/
Python Basics: Modules and Packages (Exercises) 02:55 https://realpython.com/lessons/python-modules-packages-exercises/
Python Basics: Modules and Packages (Quiz) 05:30 https://realpython.com/lessons/modules-packages-quiz/
Python Basics: Modules and Packages (Summary) 01:37 https://realpython.com/lessons/modules-packages-summary/
Privacy Policyhttps://realpython.com/privacy-policy/

Viewport: width=device-width, initial-scale=1, shrink-to-fit=no, viewport-fit=cover

Robots: max-image-preview:large


URLs of crawlers that visited me.