René's URL Explorer Experiment


Title: Structuring a Python Application (Summary) (Video) – Real Python

Open Graph Title: Structuring a Python Application (Summary) – Real Python

Description: This series of videos has talked about the file structure for your Python applications. I started off by showing you a single-file program and associated configuration files, moved up to larger applications that used modules, and then went to larger…

Open Graph Description: This series of videos has talked about the file structure for your Python applications. I started off by showing you a single-file program and associated configuration files, moved up to larger applications that used modules, and then went to larger…

Opengraph URL: https://realpython.com/lessons/structuring-python-application-summary/

X: @realpython

direct link

Domain: realpython.com


Hey, it has json ld scripts:
  {
    "@context": "https://schema.org",
    "@type": "VideoObject",
    "name": "Structuring a Python Application (Summary)",
    "description": "This series of videos has talked about the file structure for your Python applications. I started off by showing you a single\u002Dfile program and associated configuration files, moved up to larger applications that used modules, and then went to larger…",
    "thumbnailUrl": ["https://files.realpython.com/media/python_application_layout_watermark.31a037620d92.jpg"],
    "uploadDate": "2020-04-28T14:00:00+00:00",
    "duration": "PT4M39S",
    
    "potentialAction": {
      "@type": "SeekToAction",
      "target": "https://realpython.com/lessons/structuring-python-application-summary/#t={seek_to_second_number}",
      "startOffset-input": "required name=seek_to_second_number"
    }
  }
  

authorReal Python
twitter:cardsummary_large_image
twitter:imagehttps://files.realpython.com/media/python_application_layout_watermark.31a037620d92.jpg
og:imagehttps://files.realpython.com/media/python_application_layout_watermark.31a037620d92.jpg
twitter:creator@realpython
og:typevideo.episode

Links:

https://realpython.com/
Start Herehttps://realpython.com/start-here/
Learn Python https://realpython.com/lessons/structuring-python-application-summary/
Python Tutorials →In-depth articles and video courseshttps://realpython.com/search?kind=article&kind=course&order=newest
Learning Paths →Guided study plans for accelerated learninghttps://realpython.com/learning-paths/
Quizzes & Exercises →Check your learning progresshttps://realpython.com/quizzes/
Browse Topics →Focus on a specific area or skill levelhttps://realpython.com/tutorials/all/
Community Chat →Learn with other Pythonistashttps://realpython.com/community/
Office Hours →Live Q&A calls with Python expertshttps://realpython.com/office-hours/
Podcast →Hear what’s new in the world of Pythonhttps://realpython.com/podcasts/rpp/
Books →Round out your knowledge and learn offlinehttps://realpython.com/products/books/
Reference →Concise definitions for common Python termshttps://realpython.com/ref/
Code Mentor →BetaPersonalized code assistance & learning toolshttps://realpython.com/mentor/
Unlock All Content →https://realpython.com/account/join/
More https://realpython.com/lessons/structuring-python-application-summary/
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 Tutorial Writerhttps://realpython.com/write-for-us/
Become a Video Instructorhttps://realpython.com/become-an-instructor/
Searchhttps://realpython.com/search
https://realpython.com/search
Joinhttps://realpython.com/account/join/
Sign‑Inhttps://realpython.com/account/login/?next=%2Flessons%2Fstructuring-python-application-summary%2F
Unlock This Lessonhttps://realpython.com/account/join/?utm_source=rp_lesson&utm_content=structuring-python-application
Unlock This Lessonhttps://realpython.com/account/join/?utm_source=rp_lesson&utm_content=structuring-python-application
https://realpython.com/courses/structuring-python-application/#team
Structuring a Python Applicationhttps://realpython.com/courses/structuring-python-application/
Christopher Trudeauhttps://realpython.com/courses/structuring-python-application/#team
Recommended Tutorialhttps://realpython.com/python-application-layouts/
Course Slides (.pdf)https://realpython.com/courses/structuring-python-application/downloads/layout-slides/
Sample Code (.zip)https://realpython.com/courses/structuring-python-application/downloads/layout-code/
Ask a Questionhttps://realpython.com/lessons/structuring-python-application-summary/#discussion
https://realpython.com/feedback/survey/course/structuring-python-application/liked/?from=lesson-title
https://realpython.com/feedback/survey/course/structuring-python-application/disliked/?from=lesson-title
Contentshttps://realpython.com/lessons/structuring-python-application-summary/#description
Transcripthttps://realpython.com/lessons/structuring-python-application-summary/#transcript
Discussion (14)https://realpython.com/lessons/structuring-python-application-summary/#discussion
Sample Code (.zip)https://realpython.com/courses/structuring-python-application/downloads/layout-code/
Unlock This Lessonhttps://realpython.com/account/join/?utm_source=rp_lesson_preview&utm_content=structuring-python-application
Sign-Inhttps://realpython.com/account/login/
Unlock This Lessonhttps://realpython.com/account/join/?utm_source=rp_lesson_preview&utm_content=structuring-python-application
Sign-Inhttps://realpython.com/account/login/
00:00https://realpython.com/lessons/structuring-python-application-summary/#t=0.48
This series of videos has talked about the file structure for your Pythonhttps://realpython.com/lessons/structuring-python-application-summary/#t=0.48
applications.https://realpython.com/lessons/structuring-python-application-summary/#t=3.84
I started off by showing you a single-file program and associated configurationhttps://realpython.com/lessons/structuring-python-application-summary/#t=5.16
files, moved up to larger applications that used modules,https://realpython.com/lessons/structuring-python-application-summary/#t=9.24
and then went to larger applications still that used multiple modules.https://realpython.com/lessons/structuring-python-application-summary/#t=12.99
00:17https://realpython.com/lessons/structuring-python-application-summary/#t=17.55
Then, I showed you the differences in structures for web frameworkshttps://realpython.com/lessons/structuring-python-application-summary/#t=17.55
such as Django and Flask. In this lesson,https://realpython.com/lessons/structuring-python-application-summary/#t=20.7
I’m going to wrap up and then show you some variations.https://realpython.com/lessons/structuring-python-application-summary/#t=23.4
00:26https://realpython.com/lessons/structuring-python-application-summary/#t=26.43
As I mentioned in the first lesson,https://realpython.com/lessons/structuring-python-application-summary/#t=26.43
this video is based on an article by one of my colleagues at Realhttps://realpython.com/lessons/structuring-python-application-summary/#t=28.2
Python named Kyle. As a result of this,https://realpython.com/lessons/structuring-python-application-summary/#t=31.14
I’ve been able to see the comments attached to the article so I can possiblyhttps://realpython.com/lessons/structuring-python-application-summary/#t=33.81
anticipate some of your questions. Python reallyhttps://realpython.com/lessons/structuring-python-application-summary/#t=37.23
isn’t opinionated about file structure. As a result,https://realpython.com/lessons/structuring-python-application-summary/#t=40.35
there’s a lot of variation out there.https://realpython.com/lessons/structuring-python-application-summary/#t=43.17
00:45https://realpython.com/lessons/structuring-python-application-summary/#t=45.72
Desktop applications have their own intricacies.https://realpython.com/lessons/structuring-python-application-summary/#t=45.72
If you’re doing Tk or Qt,https://realpython.com/lessons/structuring-python-application-summary/#t=48.99
they both require to have modules structured in a certain way,https://realpython.com/lessons/structuring-python-application-summary/#t=51.9
and that will impact the layout. Packaging has never been Python’s strength;https://realpython.com/lessons/structuring-python-application-summary/#t=55.14
it’s always been handled through third-party libraries rather than in thehttps://realpython.com/lessons/structuring-python-application-summary/#t=59.4
built-in ones.https://realpython.com/lessons/structuring-python-application-summary/#t=62.4
01:03https://realpython.com/lessons/structuring-python-application-summary/#t=63.93
That means there’s been lots of opinions and lots of change over the years.https://realpython.com/lessons/structuring-python-application-summary/#t=63.93
There are currently a half dozen popular virtual env management tools out there,https://realpython.com/lessons/structuring-python-application-summary/#t=68.82
so I don’t expect this is going to stay static.https://realpython.com/lessons/structuring-python-application-summary/#t=73.26
01:16https://realpython.com/lessons/structuring-python-application-summary/#t=76.11
It’s going to keep changing. Online,https://realpython.com/lessons/structuring-python-application-summary/#t=76.11
there’s currently a bit of a debate about whether or not you should put yourhttps://realpython.com/lessons/structuring-python-application-summary/#t=78.69
Python source code inside of an src/ directory.https://realpython.com/lessons/structuring-python-application-summary/#t=81.69
01:25https://realpython.com/lessons/structuring-python-application-summary/#t=85.05
There’s pros and cons to this.https://realpython.com/lessons/structuring-python-application-summary/#t=85.05
The current directory that you’re in is sys.path.https://realpython.com/lessons/structuring-python-application-summary/#t=86.88
This makes it really easy to import something in a simple script,https://realpython.com/lessons/structuring-python-application-summary/#t=89.76
but it also makes it easy to make mistakes when you’re packaging.https://realpython.com/lessons/structuring-python-application-summary/#t=93.15
01:36https://realpython.com/lessons/structuring-python-application-summary/#t=96.87
Putting things inside of a src/ (source) directory forces you to test the installmenthttps://realpython.com/lessons/structuring-python-application-summary/#t=96.87
and make sure that pieces are working properly. Unfortunately,https://realpython.com/lessons/structuring-python-application-summary/#t=100.5
some IDEs have problems with this structure,https://realpython.com/lessons/structuring-python-application-summary/#t=103.95
so it can make your life a little more complicated depending on what toolshttps://realpython.com/lessons/structuring-python-application-summary/#t=106.14
you’re using. And, the Python packaging authority does not currently use thishttps://realpython.com/lessons/structuring-python-application-summary/#t=109.32
mechanism. The debate rages on though. Throughout the lessons,https://realpython.com/lessons/structuring-python-application-summary/#t=113.1
you’ve seen me using setup.py. In addition to setup.py, there’s somethinghttps://realpython.com/lessons/structuring-python-application-summary/#t=117.33
called setup.cfg. setup.pyhttps://realpython.com/lessons/structuring-python-application-summary/#t=121.38
is an actual Python program—setup.cfg is just a data file.https://realpython.com/lessons/structuring-python-application-summary/#t=123.96
02:08https://realpython.com/lessons/structuring-python-application-summary/#t=128.94
You can specify a lot of the same type of configuration in a CFG filehttps://realpython.com/lessons/structuring-python-application-summary/#t=128.94
as you can inside of setup.py. The file format uses an INI style declarationhttps://realpython.com/lessons/structuring-python-application-summary/#t=132.57
and it’s an easier way of providing defaults,https://realpython.com/lessons/structuring-python-application-summary/#t=137.82
so if your installer of choice wants to be able to give the person doing thehttps://realpython.com/lessons/structuring-python-application-summary/#t=140.13
installation some choices,https://realpython.com/lessons/structuring-python-application-summary/#t=144.36
using a text file to provide those choices and then allowing them to behttps://realpython.com/lessons/structuring-python-application-summary/#t=146.85
overwritten is easier. And although CFG is supported,https://realpython.com/lessons/structuring-python-application-summary/#t=150.69
it doesn’t seem to be as popular as setup.py,https://realpython.com/lessons/structuring-python-application-summary/#t=154.92
but that might just be because I tend to spend a lot of my time looking at olderhttps://realpython.com/lessons/structuring-python-application-summary/#t=157.47
code. Another variation is where to put the tests/ folder.https://realpython.com/lessons/structuring-python-application-summary/#t=160.59
02:44https://realpython.com/lessons/structuring-python-application-summary/#t=164.55
Some programmers prefer to put this inside of the module directory instead ofhttps://realpython.com/lessons/structuring-python-application-summary/#t=164.55
the project route. This works fine enough.https://realpython.com/lessons/structuring-python-application-summary/#t=168.09
If you don’t want to include your tests inside of your package object,https://realpython.com/lessons/structuring-python-application-summary/#t=171.51
it means you have to update your manifest files in order to make sure that theyhttps://realpython.com/lessons/structuring-python-application-summary/#t=174.66
don’t get bundled.https://realpython.com/lessons/structuring-python-application-summary/#t=177.75
02:59https://realpython.com/lessons/structuring-python-application-summary/#t=179.11
One of the reasons to put it inside of your module files is to have your unithttps://realpython.com/lessons/structuring-python-application-summary/#t=179.11
tests in with the modules, and then if you have separate integration tests,https://realpython.com/lessons/structuring-python-application-summary/#t=182.71
have that out at the project directory.https://realpython.com/lessons/structuring-python-application-summary/#t=186.04
03:08https://realpython.com/lessons/structuring-python-application-summary/#t=188.2
You’ll see some of these variations out there as you go through other people’shttps://realpython.com/lessons/structuring-python-application-summary/#t=188.2
code. What about the virtual environment? Where should you put it? Well,https://realpython.com/lessons/structuring-python-application-summary/#t=191.23
the short answer is: it kind of depends. This is mostly a personal preference,https://realpython.com/lessons/structuring-python-application-summary/#t=195.37
but the tools that you’re using may have different expectations.https://realpython.com/lessons/structuring-python-application-summary/#t=199.48
03:23https://realpython.com/lessons/structuring-python-application-summary/#t=203.38
The Real Python Pipenv guide talks about virtual environments and how tohttps://realpython.com/lessons/structuring-python-application-summary/#t=203.38
create them and how to use them, if you’re looking for more information.https://realpython.com/lessons/structuring-python-application-summary/#t=206.74
03:31https://realpython.com/lessons/structuring-python-application-summary/#t=211.03
One of the reasons to stick with fairly standard file structures is it makes ithttps://realpython.com/lessons/structuring-python-application-summary/#t=211.03
easier for youhttps://realpython.com/lessons/structuring-python-application-summary/#t=214.3
to use tools out there that have expectations. tox is used for testing yourhttps://realpython.com/lessons/structuring-python-application-summary/#t=214.79
program against multiple versions of Python and has expectations about your filehttps://realpython.com/lessons/structuring-python-application-summary/#t=219.37
structure and setup.py. twine is for uploading your package to pypi.org,https://realpython.com/lessons/structuring-python-application-summary/#t=223.33
if you’re sharing it, and it expects the distribution wheel created by setup.py.https://realpython.com/lessons/structuring-python-application-summary/#t=228.07
03:52https://realpython.com/lessons/structuring-python-application-summary/#t=232.44
For large programs,https://realpython.com/lessons/structuring-python-application-summary/#t=232.44
it’s usually helpful to do a little bit of linting and formatting.https://realpython.com/lessons/structuring-python-application-summary/#t=234.58
There’s plenty of choice for linters and checkers out there: pyflakes,https://realpython.com/lessons/structuring-python-application-summary/#t=237.37
pylink, pychecker, pep8, and flake8 are all very good tools.https://realpython.com/lessons/structuring-python-application-summary/#t=240.58
04:05https://realpython.com/lessons/structuring-python-application-summary/#t=245.08
Something that’s become popular in the last little while is a tool called black.https://realpython.com/lessons/structuring-python-application-summary/#t=245.08
It reformats your Python code. Generally,https://realpython.com/lessons/structuring-python-application-summary/#t=248.59
this stops your teams from fighting over what code should look like.https://realpython.com/lessons/structuring-python-application-summary/#t=251.8
04:16https://realpython.com/lessons/structuring-python-application-summary/#t=256.18
Typically, the result is no one’s happy about what the code looks like,https://realpython.com/lessons/structuring-python-application-summary/#t=256.18
and that’s sort of the sign of a good compromise.https://realpython.com/lessons/structuring-python-application-summary/#t=259.39
There are also good tools out there to help you bootstrap your programshttps://realpython.com/lessons/structuring-python-application-summary/#t=262.21
using scaffolding technology. Two common ones are pyscaffoldhttps://realpython.com/lessons/structuring-python-application-summary/#t=265.3
and cookiecutter. That’s everything I wanted to say.https://realpython.com/lessons/structuring-python-application-summary/#t=269.2
04:32https://realpython.com/lessons/structuring-python-application-summary/#t=272.59
Hopefully, the content’s been useful for you. Thank you for your attention.https://realpython.com/lessons/structuring-python-application-summary/#t=272.59
April 30, 2020https://realpython.com/lessons/structuring-python-application-summary/#comment-0f6eff03-10eb-46d5-94db-55e8658a723a
realpython.com/pipenv-guidehttps://realpython.com/pipenv-guide
pyscaffold.orghttps://pyscaffold.org
cookiecutter.readthedocs.iohttps://cookiecutter.readthedocs.io
April 30, 2020https://realpython.com/lessons/structuring-python-application-summary/#comment-4941f505-ff68-4799-864e-41b7d91ba316
May 1, 2020https://realpython.com/lessons/structuring-python-application-summary/#comment-b66f5c67-e50e-4b1d-898b-1bcf26e31b39
May 14, 2020https://realpython.com/lessons/structuring-python-application-summary/#comment-ef5e6107-27e4-4f22-af53-6594aaf2d6af
June 16, 2020https://realpython.com/lessons/structuring-python-application-summary/#comment-226621aa-7981-488a-83c9-4c7a39352beb
Aug. 10, 2020https://realpython.com/lessons/structuring-python-application-summary/#comment-0f1b73da-0032-4a36-8e57-c559de8ae687
Aug. 10, 2020https://realpython.com/lessons/structuring-python-application-summary/#comment-f6756149-9eec-4f30-8ed1-bfda5e46d1dd
Oct. 9, 2020https://realpython.com/lessons/structuring-python-application-summary/#comment-146f4020-cb2b-47f6-a0f0-ec7b5feef7ce
Jan. 12, 2022https://realpython.com/lessons/structuring-python-application-summary/#comment-a1d8f04c-50f9-429d-9590-f483fdc34bb5
May 16, 2022https://realpython.com/lessons/structuring-python-application-summary/#comment-283bba8d-47c4-464f-95d7-dbbed7982a1d
April 12, 2023https://realpython.com/lessons/structuring-python-application-summary/#comment-696037ca-ad47-48da-937c-1a0cc0ab6aeb
April 13, 2023https://realpython.com/lessons/structuring-python-application-summary/#comment-097a3123-943d-4b23-ac26-3db52901c258
Aug. 21, 2025https://realpython.com/lessons/structuring-python-application-summary/#comment-29b2d037-5c10-4e9a-aa6b-7570e248352d
Aug. 21, 2025https://realpython.com/lessons/structuring-python-application-summary/#comment-ad52e898-e985-4ea5-b821-332433441f79
Become a Memberhttps://realpython.com/account/join/
https://realpython.com/lessons/flask-web-application/
Overviewhttps://realpython.com/courses/structuring-python-application/
Structuring a Python Application (Overview) 12:25 https://realpython.com/videos/structuring-python-application/
Installable Single Package 06:11 https://realpython.com/lessons/installable-single-package/
Application With Internal Packages 06:23 https://realpython.com/lessons/application-internal-packages/
Django Web Application 04:19 https://realpython.com/lessons/django-web-application/
Flask Web Application 01:58 https://realpython.com/lessons/flask-web-application/
Structuring a Python Application (Summary) 04:39 https://realpython.com/lessons/structuring-python-application-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.