Prepstellar

Python Fundamentals · Getting started

20 cards

The Python Language, System, and Ecosystem

Swipe, scroll or use ← →
  1. One word, four different things

    "Python" is used for the rules of the code, for the program that runs it, for the modules that come with it, and sometimes for a package someone installed last week. Keeping those apart is the fastest way to ask a useful question later, because each layer has its own documentation and its own kind of failure.

    Two of them matter immediately.

    • The Python Language Reference gives a formal definition of the language. It is where syntax and meaning are settled.
    • The interpreter executes commands interactively or runs scripts from files. It is a program on your machine that does the running.

    The language says what for means. The interpreter is what turns your file into behavior tonight.

    1 / 20
  2. One word, four different things

    Naming the layer is not academic. It decides where you go when something is wrong.

    Layer What it is Where you look
    Language Syntax, semantics, the constructs code is written in The Language Reference
    Interpreter The running program that evaluates that code Its command line and installation
    Modules and packages Units your program is split into Your own code
    Standard library Facilities distributed with Python The library reference
    Third-party components Everything installed from outside The project's own documentation

    A syntax question and a "why is this module missing" question look similar in a chat message and belong to completely different layers.

    2 / 20
  3. Quick check

    Someone says "Python" for the rules that give code its meaning, and again for the program that runs a script. Which split is correct?

    1. AThe Package Index defines the rules; a module runs the script

      The Package Index is a source of community components; it defines no syntax and runs nothing.

    2. BThe standard library defines the rules; the language runs the script

      The standard library is a set of distributed modules rather than the definition of the language, and a language does not execute anything by itself.

    3. CThe language defines the code; the interpreter executes it, interactively or from a file

      Right. The Language Reference gives the formal definition, and the interpreter executes commands interactively or runs scripts from files.

    3 / 20

  4. What the language itself supplies

    The language is not only syntax rules; it also hands your program a starting vocabulary. The language supplies expressions, statements, functions, classes, and exceptions that programs combine. Those are the moving parts every later lesson builds on: a value is computed, an action is performed, behavior is named, structure is grouped, and failure is signalled.

    Alongside them come the values themselves. Built-in types such as numbers, text, lists, and dictionaries are part of the language system available to Python code. No installation and no import stands between your program and a dictionary.

    4 / 20
  5. What the language itself supplies

    That distinction is easy to lose, so it is worth stating plainly:

    Thing Layer Consequence
    if, def, class, try Language constructs Their meaning is fixed by the language definition
    Numbers, text, lists, dictionaries Built-in types Available to any Python code, with nothing to install
    The program that reads your file Interpreter It evaluates those constructs; it does not define them

    The interpreter, by contrast, is the running program that evaluates all of it. It is also the layer that can grow downwards: the Python interpreter itself can be extended with functions and data types implemented in C or C++. That is how a critical operation or an existing native library becomes reachable from Python code.

    5 / 20
  6. Quick check

    Where do lists and dictionaries belong in this picture?

    1. AThey are third-party components installed from the Package Index

      Built-in types arrive with the language itself; nothing has to be installed before a list can be used.

    2. BThey are built-in types the language makes available to Python code

      Right. Numbers, text, lists and dictionaries are built-in types of the language system, available to Python code.

    3. CThey are compile-and-link tools that must run before the interpreter starts

      Python needs no separate compile-and-link stage, and a data type is not a build tool.

    6 / 20

  7. Modules: the unit of reuse

    Once a program outgrows one file, the question becomes how to split it without copying code around. A module is a reusable unit that lets a Python program be split into code that other Python programs can use.

    Two things follow, and both are common misunderstandings:

    • A module is a unit of organization, not a different language. The code inside it is ordinary Python, executed by the same interpreter.
    • A program can define its own modules and can also use modules supplied by others. "Module" says nothing about who wrote it.

    That second point is why the word appears at three different layers later: your own modules, the modules distributed with Python, and modules obtained from the community. The mechanism is identical; only the origin changes.

    7 / 20
  8. Quick check

    A program has grown and two other programs now need the same behavior. What does moving it into a module achieve?

    1. AThe code becomes reusable by other Python programs

      Right. A module is a reusable unit that lets a program be split into code that other Python programs can use.

    2. BThe code is rewritten in a different language for each program

      A module is a unit of organization, not a different language.

    3. CThe behavior stops being Python and becomes an interpreter option

      Modules are ordinary Python code and do not change how the interpreter is started.

    8 / 20

  9. Keep your progress in the app

    That’s 3 of 7 quick checks. In the app they stay answered, and every lesson remembers where you left off.

  10. The library that comes in the box

    The standard library is distributed with Python and provides standardized solutions for many everyday programming problems. This is the layer that makes a fresh installation immediately useful: reading a file, parsing a date or running a test does not begin with choosing a dependency.

    Its modules are not all of one kind. It contains built-in modules written in C as well as modules written in Python. The ones written in C provide access to system functionality — file input and output being the classic example — that Python code could not otherwise reach; the ones written in Python supply standardized answers to problems that come up constantly.

    For a program that has to work, the implementation language of a module is usually irrelevant. For understanding the layer, it matters: the standard library is a curated set of solutions, not a single uniform block of code.

    9 / 20
  11. The library that comes in the box

    There is a second nuance behind the word "standard".

    The library reference describes what is distributed with Python and also some of the optional components commonly included in distributions. The exact availability of optional components can vary by distribution and platform. Windows installers usually carry the entire standard library and often more; on Unix-like systems Python is normally provided as a collection of packages, so the platform's own packaging tools may be needed to obtain some optional components.

    So "standard" describes the documented library baseline, not a promise that every optional component is packaged identically everywhere.

    10 / 20
  12. Quick check

    What does calling the standard library "standard" actually claim?

    1. AEvery optional component is packaged identically on every distribution and platform

      The exact availability of optional components can vary by distribution and platform.

    2. BIt contains only modules written in Python

      It contains built-in modules written in C as well as modules written in Python.

    3. CIt is distributed with Python and standardizes everyday solutions

      Right. The standard library is distributed with Python and provides standardized solutions for many everyday programming problems.

    11 / 20

  13. How wide the distributed library reaches

    Knowing that the library is wide is less useful than knowing its shape, because recognizing a family is what stops you from writing something that already exists. Standard-library facilities include built-in functions and types, text processing, data types, mathematics, files, operating-system services, command-line tools, concurrency, networking, testing, debugging, packaging, and runtime services.

    If the task is The family to look in
    Cleaning, matching or wrapping text Text processing
    Dates, containers, enumerations Data types
    Reading, writing or locating files Files and operating-system services
    Parsing arguments for a command-line tool Command-line tools
    Running work in parallel or over a network Concurrency and networking
    Checking that the program is right Testing and debugging
    12 / 20
  14. How wide the distributed library reaches

    One family deserves a note of its own. Some standard-library modules improve portability by hiding platform-specific details behind platform-neutral APIs. They exist precisely so a program does not have to branch on the operating system it happens to be running on.

    The practical rule for the whole layer is an order of questions:

    1. Can the language and its built-in types do this already?
    2. Is there a distributed module for it in one of the families above?
    3. Only then: does the wider ecosystem offer something?

    Skipping straight to step 3 is how projects acquire dependencies they did not need.

    13 / 20
  15. Quick check

    A program must read and write files without hand-writing a different system call for each operating system. Which layer should be checked first?

    1. AThe standard library, whose modules can hide platform specifics behind platform-neutral APIs

      Right. Standard-library facilities include files and operating-system services, and some modules deliberately hide platform-specific details behind platform-neutral APIs.

    2. BThe Package Index, since file access is never distributed with Python

      File input and output is part of what is distributed with Python, so a community package is not the first place to look.

    3. CA separate interpreter written for each target platform

      The interpreter already exists for those platforms; the open question is which distributed modules to use.

    14 / 20

  16. The ecosystem outside the box

    Beyond everything that ships with Python there is an active collection of hundreds of thousands of components, from individual programs and modules to packages and entire application development frameworks. Third-party modules, programs, tools, packages, and application frameworks are separate from the standard library, and the Python Package Index provides a large collection of these community components.

    The boundary is about origin, not quality. A community framework can be excellent, widely used and better suited to your problem than anything distributed with Python — and it is still not part of the standard library.

    15 / 20
  17. The ecosystem outside the box

    What installing one does, and what it does not do:

    Installing a third-party package Effect
    Adds capability to an environment The code can now import it there
    Changes which facilities belong to the standard library No — that set is fixed by what is distributed
    Guarantees the package exists on another machine No — the other environment must install it too

    That last row is why classifying a dependency correctly is worth the ten seconds it takes. A standard-library module can be assumed on a working Python installation; a community framework must be declared and installed wherever the program runs.

    16 / 20
  18. Quick check

    A team adopts an application framework published by the community and not distributed with Python. How should that dependency be classified?

    1. AAs part of the standard library, guaranteed on every installation

      The standard library is what is distributed with Python; a community framework is obtained separately.

    2. BAs a third-party package

      Right. Community modules, programs, tools, packages and application frameworks are third-party components, and the Python Package Index collects them.

    3. CAs a built-in type defined by the language itself

      Built-in types come with the language, and installing a package does not create one.

    17 / 20

  19. Key takeaways

    This vocabulary prevents the category errors that make problems hard to describe. Code is written in the Python language, executed by an interpreter, organized into modules and packages, supported by built-in facilities and the standard library, and optionally extended with third-party components. Keeping the layers separate lets you ask the right question: whether an issue concerns the language, the runtime, a distributed module, or an added dependency.

    • The language defines Python code; the interpreter executes it.
    • Modules organize reusable code, while the standard library ships standardized facilities with Python.
    • Third-party packages extend an environment and are obtained outside the standard library.
    18 / 20
  20. Key takeaways

    The documentation is split along the same lines, which is the quickest way to make the distinction pay off:

    Question Manual
    What does this syntax mean, exactly? The Language Reference, the formal definition of the language
    Which distributed module handles files, or testing? The standard-library reference
    How do I use this community framework? The project's own documentation

    Same word, three different books. Choosing between them correctly is most of what "knowing the ecosystem" means at this stage.

    19 / 20
  21. Quick check

    A programmer wants the formal definition of Python's syntax, and then documentation for the distributed file and testing modules. Which pair answers those two needs, in order?

    1. AThe Package Index, then a community framework

      The Package Index collects community components; neither entry defines the language nor documents the modules distributed with Python.

    2. BThe interactive prompt, then a list of the packages installed in the environment

      A prompt runs code and an install list shows dependencies; neither is the documentation being asked for.

    3. CThe Language Reference, then the standard-library reference

      Right. The Language Reference gives the formal definition of the language, and the library reference describes the modules distributed with Python.

    20 / 20

  22. 7 quick checks · then the test

    In the app, finishing the quick checks opens this lesson’s 10-question test, and the ones you miss come back exactly when you’re about to forget them.

The whole course, on your phone

Lessons you can read, audio you can listen to on the way to work, and practice that remembers what you got wrong.