From 6e74f07f735db30af507936144aec7b0ee451129 Mon Sep 17 00:00:00 2001 From: Mark Pilgrim Date: Fri, 30 Jul 2010 10:12:56 -0400 Subject: [PATCH] you know what this paragraph needs? less detail. --- your-first-python-program.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/your-first-python-program.html b/your-first-python-program.html index 5059051..a3e528d 100755 --- a/your-first-python-program.html +++ b/your-first-python-program.html @@ -184,7 +184,7 @@ SyntaxError: non-keyword arg after keyword arg
  1. Importing the sys module makes all of its functions and attributes available.
  2. sys.path is a list of directory names that constitute the current search path. (Yours will look different, depending on your operating system, what version of Python you’re running, and where it was originally installed.) Python will look through these directories (in this order) for a .py file whose name matches what you’re trying to import. -
  3. Actually, I lied; the truth is more complicated than that, because not all modules are stored as .py files. Some, like the sys module, are built-in modules; they are actually baked right into Python itself. Built-in modules behave just like regular modules, but their Python source code is not available, because they are not written in Python! (The sys module is written in C.) +
  4. Actually, I lied; the truth is more complicated than that, because not all modules are stored as .py files. Some are built-in modules; they are actually baked right into Python itself. Built-in modules behave just like regular modules, but their Python source code is not available, because they are not written in Python! (Like Python itself, these built-in modules are written in C.)
  5. You can add a new directory to Python’s search path at runtime by adding the directory name to sys.path, and then Python will look in that directory as well, whenever you try to import a module. The effect lasts as long as Python is running.
  6. By using sys.path.insert(0, new_path), you inserted a new directory as the first item of the sys.path list, and therefore at the beginning of Python’s search path. This is almost always what you want. In case of naming conflicts (for example, if Python ships with version 2 of a particular library but you want to use version 3), this ensures that your modules will be found and used instead of the modules that came with Python.