Core Python
Creating Beautiful Code with an Interpreted, Dynamically Typed Language
Python is an interpreted, dynamically typed language. Python uses indentation to create readable, even beautiful code. With Python’s vast array of built-in libraries, it can handle many jobs without the need for further libraries, allowing you to write useful code almost immediately. But Python's extensive network of external libraries makes it easy to add functionality based on your needs.
Language Features
Programming as Guido Intended It...
Indentation rules in Python. There are no curly braces, no begin and end keywords, no need for semicolons at the ends of lines - the only thing that organizes code into blocks, functions, or classes is indentation. If something is indented, it forms a block with everything indented at the same level until the end of the file or a line with less indentation.
While there are several options for indentation, the common standard is 4 spaces per level:
While there are several options for indentation, the common standard is 4 spaces per level:
Comments and Docstrings
To mark a comment from the current location to the end of the line, use a pound sign, '#'.
For longer comments and more complete documentation, especially at the beginning of a module or of a function or class, use a triple quoted string. You can use 3 single or 3 double quotes. Triple quoted strings can cover multiple lines and any unassigned string in a Python program is ignored. Such strings are often used for documentation of modules, functions, classes and methods. By convention, the "docstring" is the first statement in its enclosing scope. Following this convention allows automated production of documentation using the pydoc module.
In general, you use one line comments for commenting code from the point of view of a developer trying to understand the code itself. Docstrings are more properly used to document what the code does, more from the point of view of someone who is going to be using the code
Python is the sort of language that you can just dive into, so let's dive in with this example Python script:
0 Comments