René's URL Explorer Experiment


Title: Adding Objects to a Namespace (Video) – Real Python

Open Graph Title: Adding Objects to a Namespace – Real Python

Description: Before we wrap up this lesson, let me show you one more cool thing. Any new variables or functions that you add to adder.py will be accessible in main.py without you having to import anything new. So open the editor window for adder.py and add the…

Open Graph Description: Before we wrap up this lesson, let me show you one more cool thing. Any new variables or functions that you add to adder.py will be accessible in main.py without you having to import anything new. So open the editor window for adder.py and add the…

Opengraph URL: https://realpython.com/lessons/adding-namespace-objects/

X: @realpython

direct link

Domain: realpython.com


Hey, it has json ld scripts:
  {
    "@context": "https://schema.org",
    "@type": "VideoObject",
    "name": "Adding Objects to a Namespace",
    "description": "Before we wrap up this lesson, let me show you one more cool thing. Any new variables or functions that you add to adder.py will be accessible in main.py without you having to import anything new. So open the editor window for adder.py and add the…",
    "thumbnailUrl": ["https://files.realpython.com/media/Modules-and-Packages_Watermarked.bc38abc24435.jpg"],
    "uploadDate": "2023-11-14T14:00:00+00:00",
    "duration": "PT1M29S",
    
    "potentialAction": {
      "@type": "SeekToAction",
      "target": "https://realpython.com/lessons/adding-namespace-objects/#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/adding-namespace-objects/
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/adding-namespace-objects/
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%2Fadding-namespace-objects%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/adding-namespace-objects/#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/adding-namespace-objects/#description
Transcripthttps://realpython.com/lessons/adding-namespace-objects/#transcript
Discussionhttps://realpython.com/lessons/adding-namespace-objects/#discussion
00:00https://realpython.com/lessons/adding-namespace-objects/#t=0.605
Before we wrap up this lesson, let me show you one more cool thing.https://realpython.com/lessons/adding-namespace-objects/#t=0.605
Any new variables or functions that you add to adder.py will be accessiblehttps://realpython.com/lessons/adding-namespace-objects/#t=4.605
in main.py without you having to import anything new.https://realpython.com/lessons/adding-namespace-objects/#t=9.525
00:13https://realpython.com/lessons/adding-namespace-objects/#t=13.525
So open the editor window for adder.py and add the following functionhttps://realpython.com/lessons/adding-namespace-objects/#t=13.525
below the function definition of add(). defhttps://realpython.com/lessons/adding-namespace-objects/#t=18.275
double(x):https://realpython.com/lessons/adding-namespace-objects/#t=21.755
and then as the function body return x + xhttps://realpython.com/lessons/adding-namespace-objects/#t=26.135
00:31https://realpython.com/lessons/adding-namespace-objects/#t=31.225
Save the adder.py file and then open the editor window for main.pyhttps://realpython.com/lessons/adding-namespace-objects/#t=31.225
and add the following code after your print() call:https://realpython.com/lessons/adding-namespace-objects/#t=35.975
double_value = adder.double()https://realpython.com/lessons/adding-namespace-objects/#t=39.995
And then you pass in value as the argument.https://realpython.com/lessons/adding-namespace-objects/#t=47.435
00:50https://realpython.com/lessons/adding-namespace-objects/#t=50.595
That’s the variable you defined two lines above.https://realpython.com/lessons/adding-namespace-objects/#t=50.595
And then in the next line, you do a print() function call forhttps://realpython.com/lessons/adding-namespace-objects/#t=54.155
double_value.https://realpython.com/lessons/adding-namespace-objects/#t=58.815
Now, save and run main.py.https://realpython.com/lessons/adding-namespace-objects/#t=60.54
01:04https://realpython.com/lessons/adding-namespace-objects/#t=64.725
When you run the module,https://realpython.com/lessons/adding-namespace-objects/#t=64.725
there is no error, and the values 4 and 8 are displayed in the interactivehttps://realpython.com/lessons/adding-namespace-objects/#t=65.745
window.https://realpython.com/lessons/adding-namespace-objects/#t=70.335
So since double() already exists in the namespace,https://realpython.com/lessons/adding-namespace-objects/#t=70.793
no NameError is raised and you can use it right away.https://realpython.com/lessons/adding-namespace-objects/#t=74.995
01:18https://realpython.com/lessons/adding-namespace-objects/#t=78.475
That’s pretty convenient.https://realpython.com/lessons/adding-namespace-objects/#t=78.475
And if you aren’t convinced yet why modules are handy,https://realpython.com/lessons/adding-namespace-objects/#t=81.065
let me show you a slide with some bold words on it.https://realpython.com/lessons/adding-namespace-objects/#t=84.865
Become a Memberhttps://realpython.com/account/join/
https://realpython.com/lessons/dot-notation-imported-objects/
Overviewhttps://realpython.com/courses/python-basics-modules-packages/
https://realpython.com/lessons/break-program-into-modules/
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.