Blog

python tutorials and learn python

Created with Sketch.

Python Packages

Python Packages Summary: in this tutorial, you learn about the Python packages and how to use them to structure your application. Introduction to Python packages Suppose that you need to develop a large application that handles the sales process from order to cash. The application will have many modules. When the number of modules grows,…
Read more

Python __name__

Python __name__ Summary: in this tutorial, you’ll learn about the Python __name__ variable and how to use it effectively in modules. What’s Python __name__? If you have gone through Python code, you’ve likely seen the __name__ variable like the following: if __name__ == ‘__main__’: main() Code language: Python (python) And you might wonder what the…
Read more

Python Module Search Path

Python Module Search Path Summary: in this tutorial, you’ll learn how the module search path works in Python when you import a module into a program. Introduction to Python module search path When you import a module in a program: import module Code language: Python (python) Python will search for the module.py file from the…
Read more

Python Modules

Python Modules Summary: in this tutorial, you’ll learn about Python modules, how to import objects from a module, and how to develop your modules. Introduction to Python modules A module is a piece of software that has a specific functionality. A Python module is a file that contains Python code. For example, when building a…
Read more

Python Type Hints

Python Type Hints Summary: in this tutorial, you’ll learn about the python type hints and how to use the mypy tool to check types statically. Introduction to Python type hints Some programming languages have static typing, such as C/C++. It means that you need to declare types of variables, parameters, and return values of a…
Read more

Python Partial Functions

Python Partial Functions Summary: In this tutorial, you’ll learn about Python partial functions and how to define partial functions using the partial function from the functools module. Introduction to Python partial functions The following example defines a function that multiplies two arguments: def multiply(a, b): return a*b Code language: Python (python) Sometimes, you just want…
Read more

Python **kwargs

Python **kwargs Summary: in this tutorial, you’ll learn about the Python **kwargs parameters. Introduction to the Python **kwargs parameters In Python, a function can have a parameter preceded by two stars (**). For example: **kwwargs The **kwargs is called a keyword parameter. When a function has the **kwargs parameter, it can accept a variable number…
Read more

Python *args

Python *args Summary: in this tutorial, you’ll learn about the Python *args parameters and how to use them for defining variadic functions. Tuple unpacking The following unpacks a tuple into two variables: x, y = 10, 20   Python assigns 10 to x and 20 to y. It’s similar to passing two arguments to a…
Read more

Python Unpacking Tuple

Python Unpacking Tuple Summary: in this tutorial, you’ll learn how to unpack tuples in Python. Reviewing Python tuples Python defines a tuple using commas (,), not parentheses (). For example, the following defines a tuple with two elements: 1,2 Code language: Python (python) Python uses the parentheses to make the tuple clearer: (1, 2) Code…
Read more

Python do…while Loop Statement Emulation

Python do…while Loop Statement Emulation Summary: in this tutorial, you’ll learn how to emulate the do…while loop statement in Python Introduction to the do…while loop statement If you have come from other programming languages such as JavaScript, Java, or C#, you’re already familiar with the do…while loop statement. Unlike the while loop, the do…while loop…
Read more