diff --git a/examples/A01_introduction/01_hello_world.py b/examples/A01_introduction/01_hello_world.py index 04d4aec..db139e9 100644 --- a/examples/A01_introduction/01_hello_world.py +++ b/examples/A01_introduction/01_hello_world.py @@ -1,5 +1,5 @@ # Hello World -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # This simple program prints "Hello world!" and performs a basic # addition (1 + 1) to highlight Python's core syntax. diff --git a/examples/A01_introduction/02_print_function.py b/examples/A01_introduction/02_print_function.py index 6a37744..2efc311 100644 --- a/examples/A01_introduction/02_print_function.py +++ b/examples/A01_introduction/02_print_function.py @@ -1,5 +1,5 @@ # Use the print() function to output text to the console. -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # The print() function is used to output data to the screen. It can take # multiple arguments and will convert them to strings before printing them. diff --git a/examples/A01_introduction/03_statements.py b/examples/A01_introduction/03_statements.py index eab7c42..acfa612 100644 --- a/examples/A01_introduction/03_statements.py +++ b/examples/A01_introduction/03_statements.py @@ -1,5 +1,5 @@ # Use statements to perform actions in Python. -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # A statement is a piece of code that performs an action. It can be as simple # as a single line or a more complex block of code. The following is true # for all statements: diff --git a/examples/A01_introduction/04_expressions.py b/examples/A01_introduction/04_expressions.py index 2a0f4d5..439e518 100644 --- a/examples/A01_introduction/04_expressions.py +++ b/examples/A01_introduction/04_expressions.py @@ -1,5 +1,5 @@ # Use expressions to evaluate values in Python. -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # An expression is anything that evaluates to a value. The following is true # for all expressions: # diff --git a/examples/A01_introduction/05_modules.py b/examples/A01_introduction/05_modules.py index df358ae..0f152f9 100644 --- a/examples/A01_introduction/05_modules.py +++ b/examples/A01_introduction/05_modules.py @@ -1,5 +1,5 @@ # Use import to access Python code from other files. -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # A module is a file containing Python code. It can define functions, # classes, and variables that you can use in your code. You can import a # module using the `import` statement. diff --git a/examples/A01_introduction/06_zen_of_python.py b/examples/A01_introduction/06_zen_of_python.py index 79bb07b..63d702a 100644 --- a/examples/A01_introduction/06_zen_of_python.py +++ b/examples/A01_introduction/06_zen_of_python.py @@ -1,5 +1,5 @@ # Import the `this` module to print the Zen of Python -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # This is a fun Easter egg in Python that prints the Zen of Python, the # guiding principles for writing computer programs in Python. It emphasizes # simplicity, readability, and the importance of explicitness in code design. diff --git a/examples/A02_variables/01_problem_without_variables.py b/examples/A02_variables/01_problem_without_variables.py index b38707a..1b3854e 100644 --- a/examples/A02_variables/01_problem_without_variables.py +++ b/examples/A02_variables/01_problem_without_variables.py @@ -1,5 +1,5 @@ # Problem without variables -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # This example explains why variables are useful. Without them we would # repeat the same value throughout the code and update each occurrence # manually. Imagine printing "Hello world" 1000 times and later wanting diff --git a/examples/A02_variables/02_solution_with_variables.py b/examples/A02_variables/02_solution_with_variables.py index a8fd08c..bc36e91 100644 --- a/examples/A02_variables/02_solution_with_variables.py +++ b/examples/A02_variables/02_solution_with_variables.py @@ -1,5 +1,5 @@ # Solution: Variables as containers for data -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # This code uses a variable as a container for data. The variable `text` # stores a string value that can be reused multiple times, illustrating how # variables allow you to store and manipulate data efficiently. diff --git a/examples/A02_variables/03_integer_numbers.py b/examples/A02_variables/03_integer_numbers.py index b7177f9..2a93c4e 100644 --- a/examples/A02_variables/03_integer_numbers.py +++ b/examples/A02_variables/03_integer_numbers.py @@ -1,5 +1,5 @@ # Integer numbers -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # The integer type in Python is used to represent whole numbers, both # positive and negative. Python supports various bases for integers, # including decimal, binary, octal, and hexadecimal. diff --git a/examples/A02_variables/04_real_numbers.py b/examples/A02_variables/04_real_numbers.py index 3cb0256..062a754 100644 --- a/examples/A02_variables/04_real_numbers.py +++ b/examples/A02_variables/04_real_numbers.py @@ -1,5 +1,5 @@ # Real numbers -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Floating point numbers are used to represent real numbers and can be defined # in standard decimal format or scientific notation. Python's `float` type is # based on the IEEE 754 double-precision floating-point format, which provides diff --git a/examples/A02_variables/05_complex_numbers.py b/examples/A02_variables/05_complex_numbers.py index cc976aa..9d484b9 100644 --- a/examples/A02_variables/05_complex_numbers.py +++ b/examples/A02_variables/05_complex_numbers.py @@ -1,5 +1,5 @@ # Complex numbers -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # This code creates and manipulates complex numbers in Python. A complex # number is written as `a + bj`, where `a` is the real part and `b` is the # imaginary part. diff --git a/examples/A02_variables/06_boolean_numbers.py b/examples/A02_variables/06_boolean_numbers.py index 3a801e6..9e70494 100644 --- a/examples/A02_variables/06_boolean_numbers.py +++ b/examples/A02_variables/06_boolean_numbers.py @@ -1,5 +1,5 @@ # Boolean numbers -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # This example uses boolean variables to represent truth values—either # `True` or `False`. Such variables are often part of conditional # statements and logical operations. diff --git a/examples/A02_variables/07_list_data.py b/examples/A02_variables/07_list_data.py index df57b42..ba66bc2 100644 --- a/examples/A02_variables/07_list_data.py +++ b/examples/A02_variables/07_list_data.py @@ -1,5 +1,5 @@ # List data -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # The list type in Python is used to represent a collection of items. It is # important to note that lists are passed by reference (see mutability in # examples). When you assign a list to another variable, both variables point diff --git a/examples/A02_variables/08_tuple_data.py b/examples/A02_variables/08_tuple_data.py index 93ca22f..09ddc87 100644 --- a/examples/A02_variables/08_tuple_data.py +++ b/examples/A02_variables/08_tuple_data.py @@ -1,5 +1,5 @@ # Tuple data -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # A tuple is very similar to a list that is immutable, meaning it cannot be # changed after creation. Their main advantage is the memory efficiency # and performance benefits they provide over lists, especially when dealing diff --git a/examples/A02_variables/09_set_data.py b/examples/A02_variables/09_set_data.py index aa19e33..8f74ae4 100644 --- a/examples/A02_variables/09_set_data.py +++ b/examples/A02_variables/09_set_data.py @@ -1,5 +1,5 @@ # Set data -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # The set type in Python is a collection of elements with unique values. It # used to remove duplicates from a collection and to perform set operations like # union, intersection, and difference. The set type has the following diff --git a/examples/A02_variables/10_dictionary_data.py b/examples/A02_variables/10_dictionary_data.py index 837e2b1..04c3333 100644 --- a/examples/A02_variables/10_dictionary_data.py +++ b/examples/A02_variables/10_dictionary_data.py @@ -1,5 +1,5 @@ # Dictionary data -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # This code creates and manipulates dictionaries in Python. A dictionary is # a collection of key–value pairs where each key is unique. If a key # appears more than once, the last assigned value is retained. The diff --git a/examples/A02_variables/11_string_data.py b/examples/A02_variables/11_string_data.py index 84e3e97..6a9a95a 100644 --- a/examples/A02_variables/11_string_data.py +++ b/examples/A02_variables/11_string_data.py @@ -1,5 +1,5 @@ # String data -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # String variables in Python can be defined using single or double quotes. # Both types of quotes are valid and can be used interchangeably. The string # has the following characteristics: diff --git a/examples/A02_variables/12_none_type.py b/examples/A02_variables/12_none_type.py index db64053..c48d14b 100644 --- a/examples/A02_variables/12_none_type.py +++ b/examples/A02_variables/12_none_type.py @@ -1,5 +1,5 @@ # None -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # The None type in Python is used to show that the variable is not assigned # any value. It is useful when you want to indicate that a variable is # intentionally left empty or when a function does not return a value, e.g. diff --git a/examples/A02_variables/13_mutable_variables.py b/examples/A02_variables/13_mutable_variables.py index 786f320..b0b595d 100644 --- a/examples/A02_variables/13_mutable_variables.py +++ b/examples/A02_variables/13_mutable_variables.py @@ -1,5 +1,5 @@ # Mutable variables in Python -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Some variables in Python are mutable, meaning their value can be changed after # they are created allowing you to dynamic modification of their contents. The # most common mutable variable types in Python are lists, dictionaries, and diff --git a/examples/A02_variables/14_immutable_variables.py b/examples/A02_variables/14_immutable_variables.py index 9df2241..82e735a 100644 --- a/examples/A02_variables/14_immutable_variables.py +++ b/examples/A02_variables/14_immutable_variables.py @@ -1,5 +1,5 @@ # Immutable variables in Python -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Some variables in Python are immutable, meaning their value cannot be changed # after they are created. This is in contrast to mutable variables, which can # be modified after creation. diff --git a/examples/A02_variables/15_get_variable_type.py b/examples/A02_variables/15_get_variable_type.py index 7715d24..9d2a2e7 100644 --- a/examples/A02_variables/15_get_variable_type.py +++ b/examples/A02_variables/15_get_variable_type.py @@ -1,5 +1,5 @@ # Get the type of a variable -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Python offers a way to inspect the type of a variable using `type()`. Type # is a special class in Python that servers many purposes, including # determining the type of a variable. When invoked on a variable, it returns diff --git a/examples/A03_comments/01_single_line_comments.py b/examples/A03_comments/01_single_line_comments.py index b3f7a4a..b0cac18 100644 --- a/examples/A03_comments/01_single_line_comments.py +++ b/examples/A03_comments/01_single_line_comments.py @@ -1,5 +1,5 @@ # Single-line comments in Python -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # A single-line comment in Python starts with a hash symbol (#). # This code will print junior message and the sum of two numbers diff --git a/examples/A03_comments/02_multi_line_comments.py b/examples/A03_comments/02_multi_line_comments.py index 25cc940..c75e438 100644 --- a/examples/A03_comments/02_multi_line_comments.py +++ b/examples/A03_comments/02_multi_line_comments.py @@ -1,5 +1,5 @@ # Multi-line comments in Python -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Multi-line comments in Python can be created using triple quotes. """ diff --git a/examples/A04_operators/01_arithmetic_operatos.py b/examples/A04_operators/01_arithmetic_operatos.py index 24f8a82..4ebf21b 100644 --- a/examples/A04_operators/01_arithmetic_operatos.py +++ b/examples/A04_operators/01_arithmetic_operatos.py @@ -1,5 +1,5 @@ # Arithmetic Operators in Python -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Arithmetic operators are used to perform mathematical operations on # numeric values. In Python, these operators include addition, subtraction, # multiplication, division, floor division, modulus, and exponentiation. diff --git a/examples/A04_operators/02_comparison_operators.py b/examples/A04_operators/02_comparison_operators.py index ee8fa61..5f6b9d6 100644 --- a/examples/A04_operators/02_comparison_operators.py +++ b/examples/A04_operators/02_comparison_operators.py @@ -1,5 +1,5 @@ # Comparison Operators in Python -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Comparison operators are used to compare two values. They return a boolean # value (True or False) based on the comparison. diff --git a/examples/A04_operators/03_boolean_operators.py b/examples/A04_operators/03_boolean_operators.py index bcfb236..5397c55 100644 --- a/examples/A04_operators/03_boolean_operators.py +++ b/examples/A04_operators/03_boolean_operators.py @@ -1,5 +1,5 @@ # Boolean Operators in Python -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Boolean operators evaluate expressions to produce a boolean value, meaning # either `True` or `False`. # diff --git a/examples/A04_operators/04_identity_operators.py b/examples/A04_operators/04_identity_operators.py index 9a62f86..de99657 100644 --- a/examples/A04_operators/04_identity_operators.py +++ b/examples/A04_operators/04_identity_operators.py @@ -1,5 +1,5 @@ # Identity Operators in Python -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Identity operators are used to compare the memory locations of two objects. # If two variables point to the same object in memory, they are considered # identical. diff --git a/examples/A04_operators/05_membership_operators.py b/examples/A04_operators/05_membership_operators.py index c52b6b1..d494bfa 100644 --- a/examples/A04_operators/05_membership_operators.py +++ b/examples/A04_operators/05_membership_operators.py @@ -1,5 +1,5 @@ # Membership Operators in Python -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Membership operators are used to test whether a value is a member of a # sequence (e.g., a list, tuple, or string). diff --git a/examples/A04_operators/06_bitwise_operators.py b/examples/A04_operators/06_bitwise_operators.py index 4b717c0..fa9c57c 100644 --- a/examples/A04_operators/06_bitwise_operators.py +++ b/examples/A04_operators/06_bitwise_operators.py @@ -1,5 +1,5 @@ # Bitwise Operators in Python -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Bitwise operators are used to perform bit-level operations on integers. These # operators directly manipulate the binary representations of numbers. Each bit # is calculated independently, based on the truth table of the operation. diff --git a/examples/A04_operators/07_assignment_operators.py b/examples/A04_operators/07_assignment_operators.py index 1d38b7a..9da56a9 100644 --- a/examples/A04_operators/07_assignment_operators.py +++ b/examples/A04_operators/07_assignment_operators.py @@ -1,5 +1,5 @@ # Assignment Operators -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Assignment operators are used to assign values to variables and can also # perform operations on those values. # diff --git a/examples/A04_operators/08_conditional_operators.py b/examples/A04_operators/08_conditional_operators.py index 56e8839..2c51e01 100644 --- a/examples/A04_operators/08_conditional_operators.py +++ b/examples/A04_operators/08_conditional_operators.py @@ -1,5 +1,5 @@ # Conditional Expressions in Python -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Conditional expressions allow you to evaluate a condition and return one # of two values based on the result of the condition. # diff --git a/examples/A04_operators/09_list_operators.py b/examples/A04_operators/09_list_operators.py index 5c6ec16..cc43817 100644 --- a/examples/A04_operators/09_list_operators.py +++ b/examples/A04_operators/09_list_operators.py @@ -1,5 +1,5 @@ # Common list operators in Python -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # This file contains examples of the most commonly used operators on lists, # including indexing, slicing, concatenation, repetition, and membership tests. diff --git a/examples/A04_operators/10_tuple_operators.py b/examples/A04_operators/10_tuple_operators.py index 3418661..80960fc 100644 --- a/examples/A04_operators/10_tuple_operators.py +++ b/examples/A04_operators/10_tuple_operators.py @@ -1,5 +1,5 @@ # Tuple Operators in Python -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # This example demonstrates common tuple operations including indexing, # slicing, concatenation, repetition, and membership tests. diff --git a/examples/A04_operators/11_set_operators.py b/examples/A04_operators/11_set_operators.py index 18e0a23..dc437bb 100644 --- a/examples/A04_operators/11_set_operators.py +++ b/examples/A04_operators/11_set_operators.py @@ -1,5 +1,5 @@ # Set Operators in Python -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Demonstrates fundamental set operations including union, intersection, # difference, symmetric difference, and subset/superset checks. diff --git a/examples/A04_operators/12_dict_operators.py b/examples/A04_operators/12_dict_operators.py index d00f608..5728c78 100644 --- a/examples/A04_operators/12_dict_operators.py +++ b/examples/A04_operators/12_dict_operators.py @@ -1,5 +1,5 @@ # Merging and updating dictionaries -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Python 3.9 introduced the | and |= operators to combine dictionaries. The | # operator creates a new dictionary containing keys from both operands, while # |= updates the dictionary on the left in place. This provides a concise diff --git a/examples/A05_user_input/01_user_input_python3.py b/examples/A05_user_input/01_user_input_python3.py index 263af2e..24619c3 100644 --- a/examples/A05_user_input/01_user_input_python3.py +++ b/examples/A05_user_input/01_user_input_python3.py @@ -1,5 +1,5 @@ # User Input in Python 3 -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Use `input()` to get input from the user, which returns a string. Use `eval()` # to evaluate the input as a Python expression, or `int()` to convert it to # an integer. diff --git a/examples/A05_user_input/02_user_input_python2.py b/examples/A05_user_input/02_user_input_python2.py index dcc0bf9..c8f40e3 100644 --- a/examples/A05_user_input/02_user_input_python2.py +++ b/examples/A05_user_input/02_user_input_python2.py @@ -1,5 +1,5 @@ # User Input in Python 2 -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Use `input()` to execute the input as Python code, or `raw_input()` to get a # string input. Please not that this example works in Python 2.x only. diff --git a/examples/A05_user_input/03_user_input_with_six.py b/examples/A05_user_input/03_user_input_with_six.py index db768e2..b12a2b1 100644 --- a/examples/A05_user_input/03_user_input_with_six.py +++ b/examples/A05_user_input/03_user_input_with_six.py @@ -1,5 +1,5 @@ # Cross-Version User Input with six -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # If the code needs to work in both Python 2 and 3, you can use the `six` # library to handle user input. diff --git a/examples/A06_strings/01_string_length.py b/examples/A06_strings/01_string_length.py index 4d3e9d6..5214179 100644 --- a/examples/A06_strings/01_string_length.py +++ b/examples/A06_strings/01_string_length.py @@ -1,5 +1,5 @@ # Calculate the length of a string -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # This snippet calculates the number of characters in a string. The # result differs from the byte length when the string contains UTF-8 # characters that use multiple bytes. diff --git a/examples/A06_strings/02_string_concatenation.py b/examples/A06_strings/02_string_concatenation.py index 7e8d15e..acea234 100644 --- a/examples/A06_strings/02_string_concatenation.py +++ b/examples/A06_strings/02_string_concatenation.py @@ -1,5 +1,5 @@ # String concatenation example -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # This code concatenates (joins) strings using the `+` operator. This # technique is common when constructing messages or combining text from # different sources. diff --git a/examples/A06_strings/03_string_interpolation.py b/examples/A06_strings/03_string_interpolation.py index 23053b1..08624de 100644 --- a/examples/A06_strings/03_string_interpolation.py +++ b/examples/A06_strings/03_string_interpolation.py @@ -1,5 +1,5 @@ # String interpolation -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # This code uses f-strings (formatted string literals) to create strings # that include variables. Expressions inside curly braces `{}` are # evaluated in place. diff --git a/examples/A06_strings/04_string_escaping.py b/examples/A06_strings/04_string_escaping.py index 64a8206..6dabffe 100644 --- a/examples/A06_strings/04_string_escaping.py +++ b/examples/A06_strings/04_string_escaping.py @@ -1,5 +1,5 @@ # Escape sequences in Python strings -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # This example uses escape sequences in strings so you can include # characters that would otherwise be difficult or impossible to type # directly. diff --git a/examples/A06_strings/05_string_indexing.py b/examples/A06_strings/05_string_indexing.py index 443ecfd..2a70d3f 100644 --- a/examples/A06_strings/05_string_indexing.py +++ b/examples/A06_strings/05_string_indexing.py @@ -1,5 +1,5 @@ # String indexing -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # This code accesses individual characters in a string by index. Strings are # sequences of characters, so index 0 refers to the first character, and # negative indices let you read characters from the end of the string. diff --git a/examples/A06_strings/06_string_slicing.py b/examples/A06_strings/06_string_slicing.py index ff7fa01..7fedc63 100644 --- a/examples/A06_strings/06_string_slicing.py +++ b/examples/A06_strings/06_string_slicing.py @@ -1,5 +1,5 @@ # String slicing -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # This code slices strings in Python. Slicing extracts a portion of a string # by specifying a start index, an end index, and an optional step using # the syntax `string[start:end:step]`. diff --git a/examples/A06_strings/07_string_splitting.py b/examples/A06_strings/07_string_splitting.py index 8e83d0b..afb3614 100644 --- a/examples/A06_strings/07_string_splitting.py +++ b/examples/A06_strings/07_string_splitting.py @@ -1,5 +1,5 @@ # Splitting Strings -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # The `split()` method is used to split a string into a list of tokens based # on a specified separator. If no separator is provided, it defaults to # whitespace. The `splitlines()` method is used to split a string into a diff --git a/examples/A06_strings/08_string_joining.py b/examples/A06_strings/08_string_joining.py index 464ca90..bb9c3c3 100644 --- a/examples/A06_strings/08_string_joining.py +++ b/examples/A06_strings/08_string_joining.py @@ -1,5 +1,5 @@ # String joining -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # The `join()` method is a string method that takes an iterable (like a list) # and concatenates its elements into a single string, with a specified separator # between each element. If no separator is provided, it defaults to an empty diff --git a/examples/A06_strings/09_string_case.py b/examples/A06_strings/09_string_case.py index f987f43..25e831e 100644 --- a/examples/A06_strings/09_string_case.py +++ b/examples/A06_strings/09_string_case.py @@ -1,5 +1,5 @@ # String case manipulation examples -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # This code applies various string case manipulation methods in Python. # Store the string to be manipulated diff --git a/examples/A07_control_flow/01_if_statement.py b/examples/A07_control_flow/01_if_statement.py index 5a135a8..9e80002 100644 --- a/examples/A07_control_flow/01_if_statement.py +++ b/examples/A07_control_flow/01_if_statement.py @@ -1,5 +1,5 @@ # Conditional logic using `if`, `elif`, and `else` to handle different cases based on conditions. -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # The conditional statements in Python allow you to control the flow of your # program based on certain conditions. This way we can execute different # blocks of code depending on the condition that is met. diff --git a/examples/A07_control_flow/02_for_statement.py b/examples/A07_control_flow/02_for_statement.py index 3d4795c..3cac50d 100644 --- a/examples/A07_control_flow/02_for_statement.py +++ b/examples/A07_control_flow/02_for_statement.py @@ -1,5 +1,5 @@ # Iterating over sequences using `for` loops. -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Loops that use the `for` statement to iterate over a sequence or other # iterable objects are useful for executing a block of code a fixed number of # times (we know the number of iterations in advance). diff --git a/examples/A07_control_flow/03_while_statement.py b/examples/A07_control_flow/03_while_statement.py index c715cb1..507fae4 100644 --- a/examples/A07_control_flow/03_while_statement.py +++ b/examples/A07_control_flow/03_while_statement.py @@ -1,5 +1,5 @@ # Repeating code with `while` loops until a condition is met. -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Loops that use the `while` statement to repeat a block of code as long as a # condition is true. This is useful when the number of iterations is not known # beforehand, and the loop continues until a specific condition is met. diff --git a/examples/A07_control_flow/04_break_statement.py b/examples/A07_control_flow/04_break_statement.py index cdfa4ae..1bc181c 100644 --- a/examples/A07_control_flow/04_break_statement.py +++ b/examples/A07_control_flow/04_break_statement.py @@ -1,5 +1,5 @@ # Exiting loops prematurely with the `break` statement. -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # The `break` statement is used to exit a loop prematurely. It can be used in # both `for` and `while` loops. When the `break` statement is encountered, # the loop is terminated immediately, and control is transferred to the next diff --git a/examples/A07_control_flow/05_continue_statement.py b/examples/A07_control_flow/05_continue_statement.py index 539fcb5..fccd944 100644 --- a/examples/A07_control_flow/05_continue_statement.py +++ b/examples/A07_control_flow/05_continue_statement.py @@ -1,5 +1,5 @@ # Skipping iterations in loops with the `continue` statement. -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # When the `continue` statement is encountered, the rest of the code # in the current iteration is skipped, and control is transferred to the next # iteration of the loop. diff --git a/examples/A07_control_flow/06_pass_statement.py b/examples/A07_control_flow/06_pass_statement.py index 49b7b16..4543b5b 100644 --- a/examples/A07_control_flow/06_pass_statement.py +++ b/examples/A07_control_flow/06_pass_statement.py @@ -1,5 +1,5 @@ # Using `pass` as a placeholder or to handle empty code blocks. -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # The `pass` statement in Python is used as a placeholder for future code or # to handle empty code blocks. It allows you to write syntactically correct # code without implementing any functionality yet. diff --git a/examples/A08_functions/01_funcion_definition.py b/examples/A08_functions/01_funcion_definition.py index fc3e12e..9829f77 100644 --- a/examples/A08_functions/01_funcion_definition.py +++ b/examples/A08_functions/01_funcion_definition.py @@ -1,5 +1,5 @@ # Anatomy of a Python function -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # A function definition begins with the ``def`` keyword followed by its name and # parameters. The body can perform operations using those parameters and return # a value. Well-documented functions include a docstring that briefly states diff --git a/examples/A08_functions/02_positional_arguments.py b/examples/A08_functions/02_positional_arguments.py index 2cc1f32..b17d702 100644 --- a/examples/A08_functions/02_positional_arguments.py +++ b/examples/A08_functions/02_positional_arguments.py @@ -1,5 +1,5 @@ # Using positional arguments -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Each value is matched to a parameter based on where it appears, so the order # of the provided arguments matters. Positional parameters correspond directly # to the order defined in the function signature. Mixing up the order can lead diff --git a/examples/A08_functions/03_named_arguments.py b/examples/A08_functions/03_named_arguments.py index 837f62d..8748605 100644 --- a/examples/A08_functions/03_named_arguments.py +++ b/examples/A08_functions/03_named_arguments.py @@ -1,5 +1,5 @@ # Calling functions with keyword arguments -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # When a function call includes parameter names, the order of those arguments no # longer matters. Keyword arguments make the call site clearer and allow some # parameters to be skipped if they have defaults. They also pair well with diff --git a/examples/A08_functions/04_default_arguments.py b/examples/A08_functions/04_default_arguments.py index d58c42f..2ecca17 100644 --- a/examples/A08_functions/04_default_arguments.py +++ b/examples/A08_functions/04_default_arguments.py @@ -1,5 +1,5 @@ # Default arguments in functions -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Functions may define default values for parameters so callers can omit those # arguments. This simplifies the call site and allows optional behavior. # Remember that default expressions are evaluated when the function is defined. diff --git a/examples/A08_functions/05_dynamic_arguments_python3.py b/examples/A08_functions/05_dynamic_arguments_python3.py index 18636f7..21d3124 100644 --- a/examples/A08_functions/05_dynamic_arguments_python3.py +++ b/examples/A08_functions/05_dynamic_arguments_python3.py @@ -1,5 +1,5 @@ # Mixing positional arguments with keyword-only arguments -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Python 3 lets you combine regular positional parameters with ``*args`` and # keyword-only parameters that have default values. The `*` separator defines # that the positional parameters until a key-value pair is encountered. diff --git a/examples/A08_functions/06_dynamic_arguments_python2.py b/examples/A08_functions/06_dynamic_arguments_python2.py index a1a0c1a..82e0fd3 100644 --- a/examples/A08_functions/06_dynamic_arguments_python2.py +++ b/examples/A08_functions/06_dynamic_arguments_python2.py @@ -1,5 +1,5 @@ # Handling a variable number of arguments in Python 2 -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # This code captures extra positional arguments with ``*args`` and extra # keyword arguments with ``**kwargs`` when keyword-only parameters are # unavailable. In Python 3 you can declare keyword-only parameters using the diff --git a/examples/A08_functions/07_positional_only_arguments.py b/examples/A08_functions/07_positional_only_arguments.py index 15d4c1c..bc44930 100644 --- a/examples/A08_functions/07_positional_only_arguments.py +++ b/examples/A08_functions/07_positional_only_arguments.py @@ -1,5 +1,5 @@ # Positional-only arguments -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Some parameters can be declared positional-only so they cannot be passed by # name. This keeps the API minimal and prevents accidental clashes with keyword # arguments. The syntax uses a ``/`` in the parameter list to mark the end of diff --git a/examples/A08_functions/08_keyword_only_arguments.py b/examples/A08_functions/08_keyword_only_arguments.py index 5639d18..a9de788 100644 --- a/examples/A08_functions/08_keyword_only_arguments.py +++ b/examples/A08_functions/08_keyword_only_arguments.py @@ -1,5 +1,5 @@ # Keyword-only arguments -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Keyword-only parameters must be specified by name in the call. This avoids # ambiguity and makes the purpose of each argument clear. It is particularly # helpful when a function accepts many optional parameters. diff --git a/examples/A08_functions/09_unpacking_arguments.py b/examples/A08_functions/09_unpacking_arguments.py index ea6b6f9..bb291e1 100644 --- a/examples/A08_functions/09_unpacking_arguments.py +++ b/examples/A08_functions/09_unpacking_arguments.py @@ -1,5 +1,5 @@ # Argument unpacking with `*args` -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # When calling a function, the star operator can expand an iterable into # positional arguments. This allows you to store the arguments in a list or # other iterable and pass them all at once. diff --git a/examples/A08_functions/10_variable_scope.py b/examples/A08_functions/10_variable_scope.py index 1f948c6..262e13c 100644 --- a/examples/A08_functions/10_variable_scope.py +++ b/examples/A08_functions/10_variable_scope.py @@ -1,5 +1,5 @@ # Understanding variable scope in Python -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # There are two types of variable scope in Python: global and local. If a # local variable has the same name as a global variable, the local variable # will take precedence within the function. diff --git a/examples/A08_functions/11_nested_functions.py b/examples/A08_functions/11_nested_functions.py index 9ca657f..11ca4d1 100644 --- a/examples/A08_functions/11_nested_functions.py +++ b/examples/A08_functions/11_nested_functions.py @@ -1,5 +1,5 @@ # Nested functions and their access to enclosing variables -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Inner functions can access variables from the outer function that defines # them. This ability creates a closure which preserves the environment even # after the outer function has finished executing. It allows the inner function diff --git a/examples/A08_functions/12_closure_functions.py b/examples/A08_functions/12_closure_functions.py index 903ee83..3fc557f 100644 --- a/examples/A08_functions/12_closure_functions.py +++ b/examples/A08_functions/12_closure_functions.py @@ -1,5 +1,5 @@ # Closures in Python -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # A closure in Python is a function object that “remembers” values from its # enclosing scope even when that scope has finished execution. In other # words, a closure lets you bind variables from an outer function into an diff --git a/examples/A08_functions/12_function_factory.py b/examples/A08_functions/12_function_factory.py index 2741cbb..ef8520f 100644 --- a/examples/A08_functions/12_function_factory.py +++ b/examples/A08_functions/12_function_factory.py @@ -1,5 +1,5 @@ # Function factories to create specialized functions -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # A function factory returns a new function tailored to the argument it # receives. It enables creation of many small functions without repeating code. # Each generated function captures the parameters provided to the factory. diff --git a/examples/A08_functions/13_recursive_function.py b/examples/A08_functions/13_recursive_function.py index 893e1ac..ca95d48 100644 --- a/examples/A08_functions/13_recursive_function.py +++ b/examples/A08_functions/13_recursive_function.py @@ -1,5 +1,5 @@ # Recursive functions in Python -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # A recursive function repeatedly calls itself with a simpler version of the # original problem. Each call works toward a base case that stops the recursion. # This technique is often used for tasks that can be defined in terms of similar diff --git a/examples/A08_functions/14_callback_funciton.py b/examples/A08_functions/14_callback_funciton.py index 5a096a5..a581565 100644 --- a/examples/A08_functions/14_callback_funciton.py +++ b/examples/A08_functions/14_callback_funciton.py @@ -1,5 +1,5 @@ # Using callback functions to handle events -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # A callback function is passed as an argument to another function and executed # when a particular event occurs. This technique lets the caller customize # behavior without changing the callee. Callbacks are common in event-driven diff --git a/examples/A08_functions/15_functions_attributes.py b/examples/A08_functions/15_functions_attributes.py index ebb55f8..24e84db 100644 --- a/examples/A08_functions/15_functions_attributes.py +++ b/examples/A08_functions/15_functions_attributes.py @@ -1,5 +1,5 @@ # Adding attributes to functions -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Functions in Python are can have attributes. They are accessed using the dot # notation (e.g. `foo.name`), and can be used to store metadata about the # function, such as its name, description, or author. diff --git a/examples/A09_classes/01_class_as_blueprint.py b/examples/A09_classes/01_class_as_blueprint.py index 94cfa56..5a70025 100644 --- a/examples/A09_classes/01_class_as_blueprint.py +++ b/examples/A09_classes/01_class_as_blueprint.py @@ -1,5 +1,5 @@ # Class as blueprint to create objects -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # A class can act as a template from which many objects are built. This file # defines a Person blueprint containing attributes and methods that every # instance MUST have when created. Each instance of the Person class diff --git a/examples/A09_classes/02_class_outline.py b/examples/A09_classes/02_class_outline.py index fd12c23..baf6969 100644 --- a/examples/A09_classes/02_class_outline.py +++ b/examples/A09_classes/02_class_outline.py @@ -1,5 +1,5 @@ # Class structure outline -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # This file outlines common elements found in many classes such as attributes, # static methods and constructors. Organizing these pieces consistently makes # new classes easier to understand and maintain. diff --git a/examples/A09_classes/03_instance_methods.py b/examples/A09_classes/03_instance_methods.py index 26b949f..7b1ef9d 100644 --- a/examples/A09_classes/03_instance_methods.py +++ b/examples/A09_classes/03_instance_methods.py @@ -1,5 +1,5 @@ # A class instance is as concrete realization of a class -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # The code creates an instance of the Person class as a tangible object. # The constructor assigns initial values to the instance. After creation, the # object can call its methods and access stored data. diff --git a/examples/A09_classes/04_class_methods.py b/examples/A09_classes/04_class_methods.py index f0fabe4..070aad2 100644 --- a/examples/A09_classes/04_class_methods.py +++ b/examples/A09_classes/04_class_methods.py @@ -1,5 +1,5 @@ # Class method used to modify the class itself -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # In Python, class methods can be used to modify the behavior of all instances # of a class by changing class-level attributes. Class methods are defined # using the `@classmethod` decorator and take the class itself as the first diff --git a/examples/A09_classes/05_static_methods.py b/examples/A09_classes/05_static_methods.py index a3488ef..645d93d 100644 --- a/examples/A09_classes/05_static_methods.py +++ b/examples/A09_classes/05_static_methods.py @@ -1,5 +1,5 @@ # Static method are not bound to the class and can be used as utility functions -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Static methods operate without reference to a particular instance or class. # They behave like regular functions that happen to live in the class's # namespace and are often used for related utility tasks. diff --git a/examples/A09_classes/06_nested_classes.py b/examples/A09_classes/06_nested_classes.py index c9705cb..8a88589 100644 --- a/examples/A09_classes/06_nested_classes.py +++ b/examples/A09_classes/06_nested_classes.py @@ -1,5 +1,5 @@ # Nested classes for constants, settings, etc. -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Classes can contain other classes that serve as containers for related # constants or configuration. Nesting keeps these auxiliary definitions close to # the code that uses them. diff --git a/examples/A09_classes/07_object_construction.py b/examples/A09_classes/07_object_construction.py index 1f95fe5..3b4e6c3 100644 --- a/examples/A09_classes/07_object_construction.py +++ b/examples/A09_classes/07_object_construction.py @@ -1,5 +1,5 @@ # How __new__ and __init__ cooperate in object creation -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Object creation begins with __new__, which allocates the instance. The fresh # object is then passed to __init__ for further initialization. Separating these # steps gives developers flexibility to customize how objects come into diff --git a/examples/A09_classes/08_property_decorator.py b/examples/A09_classes/08_property_decorator.py index 13da41a..71cb08e 100644 --- a/examples/A09_classes/08_property_decorator.py +++ b/examples/A09_classes/08_property_decorator.py @@ -1,5 +1,5 @@ # Property used to encapsulate an instance variable -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # The `@property` decorator exposes getter and setter functions as attribute # access. This allows validation or computation while keeping the public # interface simple as if it were a regular attribute accessed using dot diff --git a/examples/A09_classes/09_named_constructors.py b/examples/A09_classes/09_named_constructors.py index 1938919..1b4e334 100644 --- a/examples/A09_classes/09_named_constructors.py +++ b/examples/A09_classes/09_named_constructors.py @@ -1,5 +1,5 @@ # Named constructors provide alternative ways to create instances of a class -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # A class can offer several named constructors for convenience. Each one accepts # parameters tailored for a specific situation and returns a configured # instance. diff --git a/examples/A09_classes/10_linear_inheritance.py b/examples/A09_classes/10_linear_inheritance.py index 4319e7b..294a7ce 100644 --- a/examples/A09_classes/10_linear_inheritance.py +++ b/examples/A09_classes/10_linear_inheritance.py @@ -1,5 +1,5 @@ # Multilevel inheritance -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Multilevel inheritance arranges classes in a linear hierarchy. Each # subsequent class extends the one above it, accumulating behavior down the # chain. diff --git a/examples/A09_classes/11_multiple_inheritance.py b/examples/A09_classes/11_multiple_inheritance.py index 4a03b8c..f83acce 100644 --- a/examples/A09_classes/11_multiple_inheritance.py +++ b/examples/A09_classes/11_multiple_inheritance.py @@ -1,5 +1,5 @@ # Multiple inheritance -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # A single class may inherit behavior from several parents. Combining features # this way can reduce duplication but requires careful design to avoid # conflicts. diff --git a/examples/A09_classes/12_superclass_keyword.py b/examples/A09_classes/12_superclass_keyword.py index 1e9a6fa..e9f5c18 100644 --- a/examples/A09_classes/12_superclass_keyword.py +++ b/examples/A09_classes/12_superclass_keyword.py @@ -1,5 +1,5 @@ # Call __new__ method of super class -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # A subclass can override __new__ while still delegating part of the creation # process to its parent. Calling the superclass method ensures base attributes # are initialized correctly. diff --git a/examples/A09_classes/13_method_resolution_order.py b/examples/A09_classes/13_method_resolution_order.py index 0d65d57..297c2c2 100644 --- a/examples/A09_classes/13_method_resolution_order.py +++ b/examples/A09_classes/13_method_resolution_order.py @@ -1,5 +1,5 @@ # MRO (Method Resolution Order) - bottom first -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # The method resolution order (MRO) in Python is the order in which Python # looks for methods in a class hierarchy. It is particularly important in # multiple inheritance scenarios, where a class inherits from multiple parent diff --git a/examples/A09_classes/14_diamond_problem.py b/examples/A09_classes/14_diamond_problem.py index f8467d5..4b6cac0 100644 --- a/examples/A09_classes/14_diamond_problem.py +++ b/examples/A09_classes/14_diamond_problem.py @@ -1,5 +1,5 @@ # Mro (method resolution order) - diamond problem -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # A diamond inheritance pattern occurs when two classes share a common base # class. The method resolution order ensures that the base is initialized only # once. The classes here are organized so that each path to the base is diff --git a/examples/A09_classes/15_unresolved_mro.py b/examples/A09_classes/15_unresolved_mro.py index fe0050a..9c629ab 100644 --- a/examples/A09_classes/15_unresolved_mro.py +++ b/examples/A09_classes/15_unresolved_mro.py @@ -1,5 +1,5 @@ # Mro (method resolution order) - unresolved -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Some inheritance graphs produce conflicting search orders that Python cannot # resolve. This file sets up such a conflict and triggers an error when the # interpreter tries to build the method resolution order. Understanding this diff --git a/examples/A11_exceptions/01_handling_exceptions.py b/examples/A11_exceptions/01_handling_exceptions.py index 2339c99..ef94f45 100644 --- a/examples/A11_exceptions/01_handling_exceptions.py +++ b/examples/A11_exceptions/01_handling_exceptions.py @@ -1,5 +1,5 @@ # Structured Exception Handling -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Uses try/except/else/finally blocks to handle expected and unexpected errors. import time diff --git a/examples/A11_exceptions/02_program_flow_without_try_except.py b/examples/A11_exceptions/02_program_flow_without_try_except.py index d259635..5c9f977 100644 --- a/examples/A11_exceptions/02_program_flow_without_try_except.py +++ b/examples/A11_exceptions/02_program_flow_without_try_except.py @@ -1,5 +1,5 @@ # Control Flow without try/except -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Illustrates manual error checking when no exception handlers are used. def func_a(x): diff --git a/examples/A11_exceptions/03_program_flow_with_try_except.py b/examples/A11_exceptions/03_program_flow_with_try_except.py index 079aaaa..d766e0d 100644 --- a/examples/A11_exceptions/03_program_flow_with_try_except.py +++ b/examples/A11_exceptions/03_program_flow_with_try_except.py @@ -1,5 +1,5 @@ # Control Flow with try/except -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Shows normal execution resuming after errors are caught and handled. def func_a(x): # Function uses and returns only positive values diff --git a/examples/A11_exceptions/04_chaining_exceptions.py b/examples/A11_exceptions/04_chaining_exceptions.py index ced402b..29be9aa 100644 --- a/examples/A11_exceptions/04_chaining_exceptions.py +++ b/examples/A11_exceptions/04_chaining_exceptions.py @@ -1,5 +1,5 @@ # Exception Chaining -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Demonstrates explicit and implicit chaining of exceptions to preserve the # original error context. diff --git a/examples/A11_exceptions/05_catching_multiple_exceptions.py b/examples/A11_exceptions/05_catching_multiple_exceptions.py index 4885b29..9eb1ebd 100644 --- a/examples/A11_exceptions/05_catching_multiple_exceptions.py +++ b/examples/A11_exceptions/05_catching_multiple_exceptions.py @@ -1,5 +1,5 @@ # Grouped Exception Handling -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Illustrates catching different members of an exception hierarchy with one # except block. diff --git a/examples/A11_exceptions/06_exception_hierarchy.py b/examples/A11_exceptions/06_exception_hierarchy.py index 126d116..2285fb0 100644 --- a/examples/A11_exceptions/06_exception_hierarchy.py +++ b/examples/A11_exceptions/06_exception_hierarchy.py @@ -1,5 +1,5 @@ # Custom Exception Hierarchy -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Defines a family of related custom exceptions and demonstrates raising each # member of the hierarchy. # diff --git a/examples/A12_docstrings/03_module_docstrings.py b/examples/A12_docstrings/03_module_docstrings.py index 6f6f12d..7dd436e 100644 --- a/examples/A12_docstrings/03_module_docstrings.py +++ b/examples/A12_docstrings/03_module_docstrings.py @@ -1,5 +1,5 @@ # Docstrings for modules -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright 2023 by # # All Rights Reserved diff --git a/examples/A13_type_hints/01_function_annotations.py b/examples/A13_type_hints/01_function_annotations.py index 6e4e9ca..669c20b 100644 --- a/examples/A13_type_hints/01_function_annotations.py +++ b/examples/A13_type_hints/01_function_annotations.py @@ -1,5 +1,5 @@ # Annotations for Python Functions -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Annotations in Python functions allow you to specify the expected types of # parameters and the return type of the function. This can help with code # readability and static type checking. diff --git a/examples/A13_type_hints/02_variable_annotations.py b/examples/A13_type_hints/02_variable_annotations.py index a531cc0..9fa85c5 100644 --- a/examples/A13_type_hints/02_variable_annotations.py +++ b/examples/A13_type_hints/02_variable_annotations.py @@ -1,5 +1,5 @@ # The typing module provides support for type hints in Python. -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # The `typing` module is used to provide support for type hints in Python. Type # hints are a way to indicate the expected data types of variables, function # parameters, and return values. This can help with code readability and diff --git a/examples/A16_decorators/01_simple_function_decorator.py b/examples/A16_decorators/01_simple_function_decorator.py index 8837506..08ddb55 100644 --- a/examples/A16_decorators/01_simple_function_decorator.py +++ b/examples/A16_decorators/01_simple_function_decorator.py @@ -1,5 +1,5 @@ # Adding attributes to functions using decorators -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Sometimes you may want to add metadata to a function, such as an author # name or version without modifying the function's code directly. A good way # to do this is by using a decorator. Decorators are functions that modify diff --git a/examples/A16_decorators/02_function_decorator.py b/examples/A16_decorators/02_function_decorator.py index 4617741..a497896 100644 --- a/examples/A16_decorators/02_function_decorator.py +++ b/examples/A16_decorators/02_function_decorator.py @@ -1,5 +1,5 @@ # Decorators to modify or extend function behavior -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # A decorator is a function that takes another function as an argument, # modifies or extends its behavior, and returns a new function. They are # related to closures, as they can access variables from the enclosing scope. diff --git a/examples/A16_decorators/03_function_decorator_with_args.py b/examples/A16_decorators/03_function_decorator_with_args.py index fc6ddf0..04f1e90 100644 --- a/examples/A16_decorators/03_function_decorator_with_args.py +++ b/examples/A16_decorators/03_function_decorator_with_args.py @@ -1,5 +1,5 @@ # Parameterized decorators in Python -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Unfortunately, Python does not support passing parameters to decorators # directly. A decorator of a function has always one argument, which is the # original function to be decorated. diff --git a/examples/A16_decorators/04_class_decorator_for_functions.py b/examples/A16_decorators/04_class_decorator_for_functions.py index 12c873a..d921a13 100644 --- a/examples/A16_decorators/04_class_decorator_for_functions.py +++ b/examples/A16_decorators/04_class_decorator_for_functions.py @@ -1,5 +1,5 @@ # Class as a decorator for functions and methods -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Defining the __call__ method allows a class to wrap functions or methods. # The decorator can maintain state between invocations and perform actions # before or after calling the original function. diff --git a/examples/A16_decorators/05_class_decorator_for_classes.py b/examples/A16_decorators/05_class_decorator_for_classes.py index 19ba692..1bba279 100644 --- a/examples/A16_decorators/05_class_decorator_for_classes.py +++ b/examples/A16_decorators/05_class_decorator_for_classes.py @@ -1,5 +1,5 @@ # Class as a decorator for a class -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # A class can implement the __call__ method and be applied as a decorator to # another class. When used this way it may attach attributes or modify the # decorated class at definition time. diff --git a/examples/A18_lambda_functions/01_lambda_function_syntax.py b/examples/A18_lambda_functions/01_lambda_function_syntax.py index f5ae55e..6f82399 100644 --- a/examples/A18_lambda_functions/01_lambda_function_syntax.py +++ b/examples/A18_lambda_functions/01_lambda_function_syntax.py @@ -1,5 +1,5 @@ # Lambda functions -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Lambda expressions provide a compact way to create anonymous functions. # They consist of a parameter list, a colon and a single expression that becomes # the return value. Because they are limited to one expression, lambdas are best diff --git a/examples/A18_lambda_functions/02_lambda_function_arguments.py b/examples/A18_lambda_functions/02_lambda_function_arguments.py index 1d1d238..5b10bf1 100644 --- a/examples/A18_lambda_functions/02_lambda_function_arguments.py +++ b/examples/A18_lambda_functions/02_lambda_function_arguments.py @@ -1,5 +1,5 @@ # Lambda functions with multiple arguments -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # A lambda expression can accept several parameters just like a regular # function. It is useful for short, inline operations where defining a full # function would be excessive. Here we compute a simple expression using five diff --git a/examples/A18_lambda_functions/03_lambda_function_assignment.py b/examples/A18_lambda_functions/03_lambda_function_assignment.py index 6513bd3..9ed71ab 100644 --- a/examples/A18_lambda_functions/03_lambda_function_assignment.py +++ b/examples/A18_lambda_functions/03_lambda_function_assignment.py @@ -1,5 +1,5 @@ # Assigning a lambda expression to a variable -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Lambda expressions can be assigned to variables to create small, unnamed # functions on the fly. Doing so lets you reuse the lambda just like a regular # function object. This pattern is handy for callbacks or short computations. diff --git a/examples/A18_lambda_functions/04_conditional_lambda_functions.py b/examples/A18_lambda_functions/04_conditional_lambda_functions.py index 751da4b..426e422 100644 --- a/examples/A18_lambda_functions/04_conditional_lambda_functions.py +++ b/examples/A18_lambda_functions/04_conditional_lambda_functions.py @@ -1,5 +1,5 @@ # Conditional lambda -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # A lambda can contain a conditional expression to produce different values # based on its input. This one returns ``1`` when the argument is positive and # ``0`` otherwise. Such compact expressions are useful for simple diff --git a/examples/A18_lambda_functions/05_lambda_function_nested_conditions.py b/examples/A18_lambda_functions/05_lambda_function_nested_conditions.py index deb4fe3..d042727 100644 --- a/examples/A18_lambda_functions/05_lambda_function_nested_conditions.py +++ b/examples/A18_lambda_functions/05_lambda_function_nested_conditions.py @@ -1,5 +1,5 @@ # Lambda function with nested conditionals -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # This lambda expression checks two ranges using nested conditional operators. # It returns ``1`` when the argument exceeds 10 or falls below -10 and ``0`` in # all other cases. The expression remains concise despite the multiple branches. diff --git a/examples/A18_lambda_functions/06_recursive_lambda_function.py b/examples/A18_lambda_functions/06_recursive_lambda_function.py index 7258cce..d0796a1 100644 --- a/examples/A18_lambda_functions/06_recursive_lambda_function.py +++ b/examples/A18_lambda_functions/06_recursive_lambda_function.py @@ -1,5 +1,5 @@ # Lambda function with recursion -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Although lambdas are typically simple, they can also be used recursively. # The expression here computes factorial by calling itself for successive # decrements. Assigning the lambda to a variable is required so it can diff --git a/examples/A18_lambda_functions/07_lambda_function_bytecodes.py b/examples/A18_lambda_functions/07_lambda_function_bytecodes.py index 3b724b9..bdb982b 100644 --- a/examples/A18_lambda_functions/07_lambda_function_bytecodes.py +++ b/examples/A18_lambda_functions/07_lambda_function_bytecodes.py @@ -1,5 +1,5 @@ # Lambda and def produce the same bytecode -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # This script compiles a lambda expression and a regular function to compare # their bytecode output. Both forms compile into nearly identical instructions. # Using ``lambda`` therefore carries no extra runtime cost compared to ``def``. diff --git a/examples/A23_meta_classes/class_create_with_type.py b/examples/A23_meta_classes/class_create_with_type.py index b1cfed5..24b38b8 100644 --- a/examples/A23_meta_classes/class_create_with_type.py +++ b/examples/A23_meta_classes/class_create_with_type.py @@ -1,5 +1,5 @@ # Using ``type`` to inspect objects and create classes -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # The built-in ``type`` function performs two unrelated tasks. When passed a # single object it returns that object's class, which can be handy for # inspection. When given a name, base classes and attributes it creates a new diff --git a/examples/A24_optimization/func_memoization.py b/examples/A24_optimization/func_memoization.py index cfdd97d..ef25e9c 100644 --- a/examples/A24_optimization/func_memoization.py +++ b/examples/A24_optimization/func_memoization.py @@ -1,5 +1,5 @@ # Memoization with an inner function that caches results -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # The inner ``memoized_fibonacci`` function stores each computed Fibonacci # number in the ``cache`` dictionary. On subsequent calls with the same # argument, the cached value is returned instead of recalculating it. This diff --git a/examples/B01_oop_pillars/class_abstract_properties.py b/examples/B01_oop_pillars/class_abstract_properties.py index 48ddc3f..75e8557 100644 --- a/examples/B01_oop_pillars/class_abstract_properties.py +++ b/examples/B01_oop_pillars/class_abstract_properties.py @@ -1,5 +1,5 @@ # Stacking decorators -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Multiple decorators can be stacked on a single attribute. In this file a # property is defined using @property together with @abstractmethod. Derived # classes must supply the concrete implementation for this decorated property. diff --git a/examples/B01_oop_pillars/class_abstract_python2.py b/examples/B01_oop_pillars/class_abstract_python2.py index b560488..678526b 100644 --- a/examples/B01_oop_pillars/class_abstract_python2.py +++ b/examples/B01_oop_pillars/class_abstract_python2.py @@ -1,5 +1,5 @@ # Abstract class using the six library for python 2 -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # The six library helps define abstract base classes that remain compatible with # Python 2. The metaclass provided by six works with decorators such as # @abstractmethod so subclasses must implement the required methods. diff --git a/examples/B01_oop_pillars/class_abstract_python3.py b/examples/B01_oop_pillars/class_abstract_python3.py index c76c3cc..01dfb92 100644 --- a/examples/B01_oop_pillars/class_abstract_python3.py +++ b/examples/B01_oop_pillars/class_abstract_python3.py @@ -1,5 +1,5 @@ # Abstract class in python 3+ -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Python 3 provides native support for abstract base classes. The ABC and # abstractmethod decorators ensure that child classes implement required # behavior. Instances cannot be created until the abstract methods are diff --git a/examples/B02_solid_principles/dependency_inversion_bad.py b/examples/B02_solid_principles/dependency_inversion_bad.py index 22a3e47..0e131b2 100644 --- a/examples/B02_solid_principles/dependency_inversion_bad.py +++ b/examples/B02_solid_principles/dependency_inversion_bad.py @@ -1,5 +1,5 @@ # Dependency Inversion Principle - Bad Example -# ------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # The Dependency Inversion Principle (DIP) dictates that high level # modules should not depend on low level ones directly. Calculator # instantiates Math itself and so is tightly coupled to it. diff --git a/examples/B02_solid_principles/dependency_inversion_good.py b/examples/B02_solid_principles/dependency_inversion_good.py index 1b4adc7..5c86ec2 100644 --- a/examples/B02_solid_principles/dependency_inversion_good.py +++ b/examples/B02_solid_principles/dependency_inversion_good.py @@ -1,5 +1,5 @@ # Dependency Inversion Principle - Good Example -# ------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # The Dependency Inversion Principle (DIP) encourages depending on # abstractions rather than concrete classes. Calculator receives an # IMath implementation, decoupling it from a specific Math class. diff --git a/examples/B02_solid_principles/interface_segregation_bad.py b/examples/B02_solid_principles/interface_segregation_bad.py index 7385e39..27f5ad1 100644 --- a/examples/B02_solid_principles/interface_segregation_bad.py +++ b/examples/B02_solid_principles/interface_segregation_bad.py @@ -1,5 +1,5 @@ # Interface Segregation Principle - Bad Example -# ------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # The Interface Segregation Principle (ISP) advises that clients # should not be forced to depend on methods they do not use. The # Device class defines unrelated operations that specific devices diff --git a/examples/B02_solid_principles/interface_segregation_good.py b/examples/B02_solid_principles/interface_segregation_good.py index 7f5c798..997f25d 100644 --- a/examples/B02_solid_principles/interface_segregation_good.py +++ b/examples/B02_solid_principles/interface_segregation_good.py @@ -1,5 +1,5 @@ # Interface Segregation Principle - Good Example -# ------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # The Interface Segregation Principle (ISP) breaks large interfaces # into focused ones. Mixins here provide only the operations each # device actually needs. diff --git a/examples/B02_solid_principles/liskov_substitution_bad.py b/examples/B02_solid_principles/liskov_substitution_bad.py index 0099138..7a29721 100644 --- a/examples/B02_solid_principles/liskov_substitution_bad.py +++ b/examples/B02_solid_principles/liskov_substitution_bad.py @@ -1,5 +1,5 @@ # Liskov Substitution Principle - Bad Example -# ------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # The Liskov Substitution Principle (LSP) requires that subclasses # can stand in for their base class. Here the work method checks # for `Baby` explicitly, so `Baby` cannot substitute `Human`. diff --git a/examples/B02_solid_principles/liskov_substitution_good.py b/examples/B02_solid_principles/liskov_substitution_good.py index 5a8a0b5..2eccfdb 100644 --- a/examples/B02_solid_principles/liskov_substitution_good.py +++ b/examples/B02_solid_principles/liskov_substitution_good.py @@ -1,5 +1,5 @@ # Liskov Substitution Principle - Good Example -# ------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # The Liskov Substitution Principle (LSP) means that objects of a # superclass should be replaceable with objects of its subclasses # without breaking the program. Each subclass here simply extends diff --git a/examples/B02_solid_principles/open_closed_bad.py b/examples/B02_solid_principles/open_closed_bad.py index c21281d..642a01a 100644 --- a/examples/B02_solid_principles/open_closed_bad.py +++ b/examples/B02_solid_principles/open_closed_bad.py @@ -1,5 +1,5 @@ # Open/Closed Principle - Bad Example -# ------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # The Open/Closed Principle (OCP) states that code should be open for # extension but closed for modification. Adding a new format here # requires changing the FileProcessor class, so OCP is violated. diff --git a/examples/B02_solid_principles/open_closed_good.py b/examples/B02_solid_principles/open_closed_good.py index 66f9291..40f43ee 100644 --- a/examples/B02_solid_principles/open_closed_good.py +++ b/examples/B02_solid_principles/open_closed_good.py @@ -1,5 +1,5 @@ # Open/Closed Principle - Good Example -# ------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # The Open/Closed Principle (OCP) says that classes should be # extendable without needing to modify their source. FileProcessor # composes formatter objects so new behaviour can be added safely. diff --git a/examples/B02_solid_principles/single_responsibility_bad.py b/examples/B02_solid_principles/single_responsibility_bad.py index 4b31f4a..19eb1a0 100644 --- a/examples/B02_solid_principles/single_responsibility_bad.py +++ b/examples/B02_solid_principles/single_responsibility_bad.py @@ -1,5 +1,5 @@ # Single Responsibility Principle - Bad Example -# ------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # The Single Responsibility Principle (SRP) says that a class should # have only one reason to change. This example bundles reading, # writing and processing into one class, so it breaks SRP. diff --git a/examples/B02_solid_principles/single_responsibility_good.py b/examples/B02_solid_principles/single_responsibility_good.py index 4bbe70d..ffc4b77 100644 --- a/examples/B02_solid_principles/single_responsibility_good.py +++ b/examples/B02_solid_principles/single_responsibility_good.py @@ -1,5 +1,5 @@ # Single Responsibility Principle - Good Example -# ------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # The Single Responsibility Principle (SRP) states that a class should # do only one thing. Here the reading, writing and processing logic # are split into separate classes. diff --git a/examples/B03_design_patterns/class_factory.py b/examples/B03_design_patterns/class_factory.py index 22ce81f..a9402c3 100644 --- a/examples/B03_design_patterns/class_factory.py +++ b/examples/B03_design_patterns/class_factory.py @@ -1,5 +1,5 @@ # Class factory using the __new__ method -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Overriding __new__ allows a class to act as a factory. The method returns an # instance of a specific subclass based on the provided parameters. This # separates the decision about which object to create from the calling code. diff --git a/examples/B03_design_patterns/conditional_inheritance.py b/examples/B03_design_patterns/conditional_inheritance.py index 167378d..52dd8ef 100644 --- a/examples/B03_design_patterns/conditional_inheritance.py +++ b/examples/B03_design_patterns/conditional_inheritance.py @@ -1,5 +1,5 @@ # Conditional inheritance using the __new__ method -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # The __new__ method can decide which subclass to instantiate. By inspecting # runtime conditions it returns objects of different types from a single # factory class. This approach allows conditional inheritance without altering diff --git a/examples/B03_design_patterns/mixin_class.py b/examples/B03_design_patterns/mixin_class.py index 0b752ba..28e0ce4 100644 --- a/examples/B03_design_patterns/mixin_class.py +++ b/examples/B03_design_patterns/mixin_class.py @@ -1,5 +1,5 @@ # Mixin class -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # A mixin provides extra methods that can be shared across multiple unrelated # classes. It relies on cooperative multiple inheritance to join its behavior # with that of the main class hierarchy. diff --git a/examples/C01_logging/logging_advanced_config.py b/examples/C01_logging/logging_advanced_config.py index adbdc08..cd0d25b 100644 --- a/examples/C01_logging/logging_advanced_config.py +++ b/examples/C01_logging/logging_advanced_config.py @@ -1,5 +1,5 @@ # Advanced Logging Configuration -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Demonstrates custom handlers, a formatter, and propagation control. import logging diff --git a/examples/C01_logging/logging_basic_config.py b/examples/C01_logging/logging_basic_config.py index 0b5b7f2..2dce3b6 100644 --- a/examples/C01_logging/logging_basic_config.py +++ b/examples/C01_logging/logging_basic_config.py @@ -1,5 +1,5 @@ # Basic Logging Configuration -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Uses basicConfig for the root logger and a named child logger. import logging diff --git a/examples/C01_logging/logging_config_dict.py b/examples/C01_logging/logging_config_dict.py index 1424e58..3b5d20e 100644 --- a/examples/C01_logging/logging_config_dict.py +++ b/examples/C01_logging/logging_config_dict.py @@ -1,5 +1,5 @@ # Logging Configuration with a Dictionary -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Uses a dict to define formatters, handlers and loggers. import logging.config diff --git a/examples/C01_logging/logging_config_file.py b/examples/C01_logging/logging_config_file.py index 182b1fc..4a9120b 100644 --- a/examples/C01_logging/logging_config_file.py +++ b/examples/C01_logging/logging_config_file.py @@ -1,5 +1,5 @@ # Configuring Logging from a File -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Loads logger settings from an external configuration file. import logging.config diff --git a/examples/C01_logging/logging_exceptions.py b/examples/C01_logging/logging_exceptions.py index 74cafca..0432943 100644 --- a/examples/C01_logging/logging_exceptions.py +++ b/examples/C01_logging/logging_exceptions.py @@ -1,5 +1,5 @@ # Logging Exceptions -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Captures an exception and logs the full stack trace. import logging diff --git a/examples/C01_logging/logging_formatter.py b/examples/C01_logging/logging_formatter.py index 3b0320d..c49b706 100644 --- a/examples/C01_logging/logging_formatter.py +++ b/examples/C01_logging/logging_formatter.py @@ -1,5 +1,5 @@ # Custom Logging Formatter -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Configures a formatter for a named logger. import logging diff --git a/examples/C01_logging/logging_handlers.py b/examples/C01_logging/logging_handlers.py index 6ff0bb0..959c3c1 100644 --- a/examples/C01_logging/logging_handlers.py +++ b/examples/C01_logging/logging_handlers.py @@ -1,5 +1,5 @@ # Multiple Logging Handlers -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Sets up stream, file and timed rotating handlers. import logging.handlers diff --git a/examples/C01_logging/logging_hierarchy.py b/examples/C01_logging/logging_hierarchy.py index 2688b7e..a85a20b 100644 --- a/examples/C01_logging/logging_hierarchy.py +++ b/examples/C01_logging/logging_hierarchy.py @@ -1,5 +1,5 @@ # Logger Hierarchy -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Shows parent, child and grandchild loggers working together. import logging diff --git a/examples/C01_logging/logging_levels.py b/examples/C01_logging/logging_levels.py index d4f91ef..3217e80 100644 --- a/examples/C01_logging/logging_levels.py +++ b/examples/C01_logging/logging_levels.py @@ -1,5 +1,5 @@ # Logging Levels -# -------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Demonstrates how to emit messages for each severity level. import logging