Category: Python

Python / Compiling Code and Creating EXE Files
Check the difference between compilation and execution with a runnable example. Use PyInstaller on Windows to build folder and single-file executables, include data files, and diagnose failures.

Python / int() / Convert Values to Integers
Convert strings and numbers with Python int(), choose a numeric base, and understand truncation and conversion errors. A runnable example restricts order quantities to ASCII digits and values from 1 to 99.

Python / Syntax / Comments
Learn to write # comments in Python, including beside items in a multi-line expression. Runnable examples distinguish triple-quoted strings and docstrings from comments and show why an otherwise empty block needs pass.

Python / dir() / Discover an Object’s Attribute Names
Explore names on strings, lists, modules, and custom objects with dir(). Learn how to use the discovered attributes, how vars() differs, and why local namespaces and custom __dir__() methods affect the result.

Python / float() / Convert Values to Floating-Point Numbers
Explore accepted input formats, conversion errors, and floating-point approximation. Complete examples cover NaN, infinity, overflow, and a function that accepts only finite numbers.

Python / str() / Convert an Object to a String
Learn how str() converts values, how numeric formatting differs from conversion, and when bytes require decoding. Examples also distinguish repr() and JSON, handle None, and explain common errors.

Python Tutorial / Package a Python Program and Verify Installation
Create a src-layout package and pyproject.toml, build a wheel, install it cleanly and verify imports and module execution outside the source checkout.

Python Tutorial / Choose Threads, Processes or asyncio
Compare thread, process and asyncio execution models, understand entry-point and event-loop rules and choose concurrency based on workload and measured costs.

Python Tutorial / Understand Decorators and Context Managers
Wrap functions with preserved metadata and results, implement cleanup with contextmanager and verify behavior when a block or wrapped call fails.

Python Tutorial / Connect to MariaDB and Manage Transactions
Prepare a least-privilege local MariaDB account, bind values through PyMySQL and manage commit, rollback, credentials and connection cleanup.