Python Program Structure And Layout

Python Code Indentation

Python uses whitespace (eg spaces and tabs) to group together lines of code that belong together. Any time a line ends with a colon, you are telling Python "hey, a block of code follows" and Python expects to see some indented code.

Comments in Python Code

The "#" starts a comment which tells Python to ignore everything after the # on that line. The "#" can be at the start of a line or after some code.

Python Documentation Strings

To document what an object does, you can place a triple-quoted string directly after the object.

Python Directory structure

A basic directory structure consists of the following:

The Python file

The file is used by the PIP installer to determine what module / package dependencies you have in your project as well as descriptive information about who the author is, what version you project (as a package) is, and so forth. In addition to external package dependencies, you can also specify the folder and Python script filename which makes it easier to import your Python modules in your code.