René's URL Explorer Experiment


Title: Make a Runnable Script (Video) – Real Python

Open Graph Title: Make a Runnable Script – Real Python

Description: Make a Runnable Script. In this section, you’ll provide a command-line interface to your Python package By using argparse. It will take a path to a binary file with your maze as input. Then it will try to find the maze’s solutions and render them in…

Open Graph Description: Make a Runnable Script. In this section, you’ll provide a command-line interface to your Python package By using argparse. It will take a path to a binary file with your maze as input. Then it will try to find the maze’s solutions and render them in…

Opengraph URL: https://realpython.com/lessons/python-maze-runnable-script/

X: @realpython

direct link

Domain: realpython.com


Hey, it has json ld scripts:
  {
    "@context": "https://schema.org",
    "@type": "VideoObject",
    "name": "Make a Runnable Script",
    "description": "Make a Runnable Script. In this section, you’ll provide a command\u002Dline interface to your Python package By using argparse. It will take a path to a binary file with your maze as input. Then it will try to find the maze’s solutions and render them in…",
    "thumbnailUrl": ["https://files.realpython.com/media/Build-a-Pac-Man-Maze-Solver-in-Python_Watermarked.c2e79a85fc99.jpg"],
    "uploadDate": "2023-06-06T14:00:00+00:00",
    "duration": "PT3M59S",
    
    "potentialAction": {
      "@type": "SeekToAction",
      "target": "https://realpython.com/lessons/python-maze-runnable-script/#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/Build-a-Pac-Man-Maze-Solver-in-Python_Watermarked.c2e79a85fc99.jpg
og:imagehttps://files.realpython.com/media/Build-a-Pac-Man-Maze-Solver-in-Python_Watermarked.c2e79a85fc99.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/python-maze-runnable-script/
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/python-maze-runnable-script/
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%2Fpython-maze-runnable-script%2F
Unlock This Lessonhttps://realpython.com/account/join/?utm_source=rp_lesson&utm_content=python-maze-solver
Unlock This Lessonhttps://realpython.com/account/join/?utm_source=rp_lesson&utm_content=python-maze-solver
https://realpython.com/courses/python-maze-solver/#team
Mazes in Python: Build, Visualize, Store, and Solvehttps://realpython.com/courses/python-maze-solver/
Darren Joneshttps://realpython.com/courses/python-maze-solver/#team
Recommended Tutorialhttps://realpython.com/python-maze-solver/
Course Slides (.pdf)https://realpython.com/courses/python-maze-solver/downloads/mazes-in-python-slides/
Sample Code (.zip)https://realpython.com/courses/python-maze-solver/downloads/mazes-in-python-code/
Ask a Questionhttps://realpython.com/lessons/python-maze-runnable-script/#discussion
https://realpython.com/feedback/survey/course/python-maze-solver/liked/?from=lesson-title
https://realpython.com/feedback/survey/course/python-maze-solver/disliked/?from=lesson-title
Contentshttps://realpython.com/lessons/python-maze-runnable-script/#description
Transcripthttps://realpython.com/lessons/python-maze-runnable-script/#transcript
Discussionhttps://realpython.com/lessons/python-maze-runnable-script/#discussion
00:00https://realpython.com/lessons/python-maze-runnable-script/#t=0.67
Make a Runnable Script.https://realpython.com/lessons/python-maze-runnable-script/#t=0.67
In this section,https://realpython.com/lessons/python-maze-runnable-script/#t=2.531
you’ll provide a command-line interface to your Python package By usinghttps://realpython.com/lessons/python-maze-runnable-script/#t=4.11
argparse.https://realpython.com/lessons/python-maze-runnable-script/#t=8.28
It will take a path to a binary file with your maze as input.https://realpython.com/lessons/python-maze-runnable-script/#t=9.444
00:13https://realpython.com/lessons/python-maze-runnable-script/#t=13.25
Then it will try to find the maze’s solutions and render them in separate tabs inhttps://realpython.com/lessons/python-maze-runnable-script/#t=13.25
your web browser as scalable vector graphics.https://realpython.com/lessons/python-maze-runnable-script/#t=17.22
If it can’t find any solutions,https://realpython.com/lessons/python-maze-runnable-script/#t=20.169
then you’ll see an appropriate message in your console.https://realpython.com/lessons/python-maze-runnable-script/#t=22.33
00:27https://realpython.com/lessons/python-maze-runnable-script/#t=27.48
Add the __main__.py file to your project to turn it into a runnable Pythonhttps://realpython.com/lessons/python-maze-runnable-script/#t=27.48
package.https://realpython.com/lessons/python-maze-runnable-script/#t=31.82
This file should live inside your maze_solver package next to the emptyhttps://realpython.com/lessons/python-maze-runnable-script/#t=33.21
__init__.py file.https://realpython.com/lessons/python-maze-runnable-script/#t=37.28
00:41https://realpython.com/lessons/python-maze-runnable-script/#t=41.55
Its contents are seen on-screen.https://realpython.com/lessons/python-maze-runnable-script/#t=41.55
01:21https://realpython.com/lessons/python-maze-runnable-script/#t=81.85
The code finds,https://realpython.com/lessons/python-maze-runnable-script/#t=81.85
renders, and previews all the solutions of the loaded maze or prints an errorhttps://realpython.com/lessons/python-maze-runnable-script/#t=83.1
message.https://realpython.com/lessons/python-maze-runnable-script/#t=87.47
01:36https://realpython.com/lessons/python-maze-runnable-script/#t=96.72
It uses the argparse module to parse the file path,https://realpython.com/lessons/python-maze-runnable-script/#t=96.72
which is currently the only expected command-line argument.https://realpython.com/lessons/python-maze-runnable-script/#t=99.75
Later, you can add more if you want to—for example,https://realpython.com/lessons/python-maze-runnable-script/#t=107.89
to allow previewing mazes without a solution.https://realpython.com/lessons/python-maze-runnable-script/#t=111.1
01:54https://realpython.com/lessons/python-maze-runnable-script/#t=114.839
Finally,https://realpython.com/lessons/python-maze-runnable-script/#t=114.839
the file uses the name-main idiom to protect the main() function from running ifhttps://realpython.com/lessons/python-maze-runnable-script/#t=115.91
other modules import the package.https://realpython.com/lessons/python-maze-runnable-script/#t=120.57
If you want to know more about using argparse,https://realpython.com/lessons/python-maze-runnable-script/#t=126.85
then check out this Real Python course.https://realpython.com/lessons/python-maze-runnable-script/#t=129.02
02:14https://realpython.com/lessons/python-maze-runnable-script/#t=134.97
To run the package, use the command seen on-screen in your terminal.https://realpython.com/lessons/python-maze-runnable-script/#t=134.97
02:30https://realpython.com/lessons/python-maze-runnable-script/#t=150.23
Optionally, you can specify a shortcut in your pyproject.toml file.https://realpython.com/lessons/python-maze-runnable-script/#t=150.23
You can have as many custom commands as you like,https://realpython.com/lessons/python-maze-runnable-script/#t=160.46
which should map to specific functions in the given module within the project.https://realpython.com/lessons/python-maze-runnable-script/#t=162.69
02:51https://realpython.com/lessons/python-maze-runnable-script/#t=171.09
To register the new command in your virtual environment,https://realpython.com/lessons/python-maze-runnable-script/#t=171.09
you must install the package using pip once more.https://realpython.com/lessons/python-maze-runnable-script/#t=173.85
03:03https://realpython.com/lessons/python-maze-runnable-script/#t=183.25
Once you’ve reinstalled the package,https://realpython.com/lessons/python-maze-runnable-script/#t=183.25
you’ll be able to solve mazes using the solve command without explicitly callinghttps://realpython.com/lessons/python-maze-runnable-script/#t=184.76
on Python.https://realpython.com/lessons/python-maze-runnable-script/#t=188.92
03:16https://realpython.com/lessons/python-maze-runnable-script/#t=196.95
Note that you need to run it from your virtual environment.https://realpython.com/lessons/python-maze-runnable-script/#t=196.95
The solve command,https://realpython.com/lessons/python-maze-runnable-script/#t=199.461
which you just created, is not available outside of it.https://realpython.com/lessons/python-maze-runnable-script/#t=200.8
You now have a working command-line interface to your Python package and ahttps://realpython.com/lessons/python-maze-runnable-script/#t=208.44
working maze solver that you can access quickly from the command line orhttps://realpython.com/lessons/python-maze-runnable-script/#t=212.22
terminal.https://realpython.com/lessons/python-maze-runnable-script/#t=216.18
03:36https://realpython.com/lessons/python-maze-runnable-script/#t=216.639
While you’ve reached the end of this two-part course,https://realpython.com/lessons/python-maze-runnable-script/#t=216.639
remember that you can always keep improving the project.https://realpython.com/lessons/python-maze-runnable-script/#t=219.64
For example,https://realpython.com/lessons/python-maze-runnable-script/#t=222.604
you could add more command-line arguments to control the rendering process orhttps://realpython.com/lessons/python-maze-runnable-script/#t=223.7
provide an option to save the results as an image instead of previewing them inhttps://realpython.com/lessons/python-maze-runnable-script/#t=227.68
the browser.https://realpython.com/lessons/python-maze-runnable-script/#t=231.6
03:52https://realpython.com/lessons/python-maze-runnable-script/#t=232.341
The possibilities are endless, but in the next part of the course,https://realpython.com/lessons/python-maze-runnable-script/#t=232.341
you’ll look back at what you’ve learned.https://realpython.com/lessons/python-maze-runnable-script/#t=236.3
Become a Memberhttps://realpython.com/account/join/
https://realpython.com/lessons/python-maze-enemies-rewards/
Overviewhttps://realpython.com/courses/python-maze-solver/
https://realpython.com/lessons/python-maze-solver-part-2-summary/
Mazes in Python: Build and Visualize 02:47 https://realpython.com/videos/python-maze-solver-part-1-overview/
Check Out What You'll Make 02:39 https://realpython.com/videos/python-maze-solver-project/
Lay the Groundwork 04:02 https://realpython.com/videos/python-maze-solver-groundwork/
Scaffold the Project Structure 04:50 https://realpython.com/lessons/python-maze-solver-structure/
Represent the Maze With Objects 06:37 https://realpython.com/lessons/represent-maze-with-objects/
Create Border Patterns 06:32 https://realpython.com/lessons/python-maze-border-patterns/
Model the Square 02:25 https://realpython.com/lessons/model-python-maze-square/
Build the Maze 09:07 https://realpython.com/lessons/build-python-maze/
Visualize the Maze With SVG 04:45 https://realpython.com/lessons/python-maze-svg/
Implement Geometric Primitives 04:48 https://realpython.com/lessons/python-maze-geometric-primitives/
Add More Primitives 03:47 https://realpython.com/lessons/python-maze-more-primitives/
Decompose the Border Into Primitives 04:41 https://realpython.com/lessons/decompose-python-maze-border/
Add More Border Patterns 03:58 https://realpython.com/lessons/python-maze-more-border-patterns/
Build the SVG Renderer 03:49 https://realpython.com/lessons/python-maze-svg-renderer/
Add Features to the Renderer 06:50 https://realpython.com/lessons/python-maze-renderer-features/
Draw the Solution 03:13 https://realpython.com/lessons/draw-python-maze-solution/
Preview the Rendered Maze and Its Solution 04:56 https://realpython.com/lessons/preview-python-maze/
Mazes in Python: Build and Visualize (Recap) 01:14 https://realpython.com/lessons/python-maze-solver-part-1-summary/
Mazes in Python: Store and Solve 01:48 https://realpython.com/videos/python-maze-solver-part-2-overview/
Load the Maze From a Binary File 04:55 https://realpython.com/videos/python-maze-binary-file/
Choose Your Data Alignment 05:09 https://realpython.com/videos/python-maze-data-alignment/
Define the File Header and Body 08:12 https://realpython.com/lessons/python-maze-file-header-and-body/
Serialize the Maze 05:22 https://realpython.com/lessons/serialize-python-maze/
Deserialize the Maze 04:32 https://realpython.com/lessons/deserialize-python-maze/
Make the Maze Self-Contained 04:30 https://realpython.com/lessons/python-self-contained-maze/
Update the Maze Class 03:16 https://realpython.com/lessons/python-maze-class/
Solve the Maze Using a Graph-Based Approach 03:01 https://realpython.com/lessons/solve-python-maze-graph-based/
Transform the Maze Into a Graph 07:06 https://realpython.com/lessons/transform-python-maze-graph/
Find the Shortest Path 05:23 https://realpython.com/lessons/python-maze-shortest-path/
Add Weights to Graph Edges 02:36 https://realpython.com/lessons/python-map-weights-graph-edges/
Introduce Enemies and Rewards 06:04 https://realpython.com/lessons/python-maze-enemies-rewards/
Make a Runnable Script 03:59 https://realpython.com/lessons/python-maze-runnable-script/
Mazes in Python: Store and Solve (Recap) 01:23 https://realpython.com/lessons/python-maze-solver-part-2-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.