Skip to content

Instantly share code, notes, and snippets.

@weshouman
Last active October 4, 2016 21:28
Show Gist options
  • Save weshouman/c52730e17067efa32912a06495803a41 to your computer and use it in GitHub Desktop.
Save weshouman/c52730e17067efa32912a06495803a41 to your computer and use it in GitHub Desktop.
setting up different environments

Creating New Project

File System Prespective

package
├── \__init\__.py
├── module.py
├── nested_package
│   ├── \__init\__.py
│   ├── other_module.py
│   └── satellizer.min.js

Example Repo

This repo could be cloned directly to investigate filesystem structure.
For each dir and file purpose, check this paragraph

How a Project Gets Imported

A file modu.py in the directory pack/ is imported with the statement import pack.modu.
This statement will look for an __init__.py file in pack, execute all of its top-level statements.
Then it will look for a file named pack/modu.py and execute all of its top-level statements.
After these operations, any variable, function, or class defined in modu.py is available in the pack.modu namespace.

This paragraph is extracted from, and more considerations could be found at, this paragraph

Hints and Design Notes

  • A module is a file ending with .py and a package is a folder containing modules and (nested) packages again
  • Python recognizes a folder as a package if it contains a _init_.py file
  • Keep modules and package names lowercase (just more pythonic)

Setup

Exploring Existing Project

Setup

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment