programming

Python Enum

Learn Python Enum with simple examples, including enum class syntax, name and value, iteration, auto(), IntEnum, StrEnum, enum methods, multiple attributes, and common mistakes.

Deepak Prasad9 min read
programming

Python Delete Variable

Learn how to delete a variable in Python using del, what happens after deleting a variable, how to clear variables, unset names, and whether del frees memory immediately.

Bashir Alam7 min read
programming

Python Break Statement: for, while, Nested Loops, and else

Learn the Python break statement to exit for and while loops early, how break behaves in nested loops, how it interacts with loop else, break vs continue, and common mistakes.

Deepak Prasad9 min read
programming

How to Get File Size in Python: pathlib, os.path, and bytes

Learn how to get file size in Python with os.path.getsize, pathlib Path.stat, and os.stat, convert bytes to KB or MB, guard large or empty files, handle errors, and sum folder sizes.

Bashir Alam6 min read
programming

Python Extend Dictionary

Learn how to extend a dictionary in Python using update(), the |= operator, the | merge operator, and dictionary unpacking. Also learn why dict has no extend() method like list.

Deepak Prasad7 min read
programming

Python Logging

Learn Python logging with simple examples. Configure logging using basicConfig(), log to console and file, use log levels, create loggers, handlers, formatters, and avoid common mistakes.

Deepak Prasad9 min read
programming

Python datetime Module

Learn Python datetime module with examples for date, time, datetime, now(), strftime(), strptime(), ctime(), timestamps, timedelta, and time zones using zoneinfo.

Deepak Prasad9 min read
programming

Python dataclass

Learn Python dataclass with simple examples, including @dataclass, default values, field(default_factory), frozen dataclasses, ordering, __post_init__, asdict(), and common mistakes.

Deepak Prasad11 min read
programming

Python Counter

Learn Python Counter from the collections module with examples to count items, words, characters, add elements, update counts, use most_common(), elements(), subtract(), and Counter arithmetic.

Bashir Alam9 min read
programming

Python casefold() String Method

Learn Python string casefold() with syntax, examples, Unicode case-insensitive comparison, casefold vs lower, and common mistakes when comparing strings.

Deepak Prasad5 min read
programming

Python if else Statement: Syntax, elif, Flowchart, and Examples

Learn the Python if, if else, and if elif else statements: syntax, indentation, elif vs else-if, conditions, flow, nested branches, ternary expressions, loop/try else, and common mistakes.

Deepak Prasad12 min read
programming

Python classmethod: @classmethod, cls, and Factory Methods

Learn Python classmethod with examples using @classmethod, cls, class variables, factory methods, return cls, and the difference between class methods, instance methods, and static methods.

Bashir Alam9 min read
programming

Python Check if File Exists

Learn how to check if a file exists in Python using pathlib Path.exists(), Path.is_file(), os.path.exists(), and os.path.isfile(), with examples for directories, symlinks, and file errors.

Deepak Prasad7 min read
programming

Python Return Multiple Values

Learn how to return multiple values from a Python function using comma-separated return values, tuple unpacking, lists, dictionaries, NamedTuple, dataclass, and common mistakes.

Deepak Prasad7 min read
programming

Python argparse Example

Learn Python argparse with practical examples for positional arguments, optional flags, default values, type conversion, choices, nargs, boolean flags, and subcommands.

Deepak Prasad9 min read
programming

Python Call Function from Another File

Learn how to call a function from another Python file using import, from import, package imports from a different directory, importlib, and fixes for ModuleNotFoundError.

Deepak Prasad6 min read
programming

Python Multithreading Examples: Thread, Lock, Queue, and ThreadPoolExecutor

Learn Python multithreading with practical examples using threading.Thread, start(), join(), daemon threads, Lock, Queue, ThreadPoolExecutor, and best practices for I/O-bound tasks.

Deepak Prasad8 min read
programming

Python Catch Multiple Exceptions

Learn how to catch multiple exceptions in Python using one except block with a tuple, separate except blocks, as e, else, finally, and best practices for handling multiple errors.

Bashir Alam6 min read
programming

List Comprehension in Python with Examples

Learn Python list comprehension: syntax, filters, if-else, range and strings, nested and multiple for loops, flattening lists of lists, map and filter alternatives, pitfalls, and a quick reference table.

Bashir Alam11 min read
programming

Python Multiprocessing Example: Process, Pool, and Queue

Learn Python multiprocessing with practical examples using Process, Pool, pool.map(), Queue, join(), CPU-bound tasks, shared data, and common multiprocessing mistakes.

Deepak Prasad10 min read
programming

Go Channels Tutorial: Send, Receive, Close, Range, and Select

Learn channels in Go, including send and receive syntax, buffered and unbuffered channels, close, range, select, deadlocks, and common concurrency patterns.

Antony Shikubu10 min read
programming

Golang exec Command: Run Shell Commands, Capture Output, and Handle Errors

Learn how to run external commands in Go using os/exec, capture stdout and stderr, pass arguments, use shell commands, set timeouts, and avoid command injection.

Deepak Prasad15 min read
programming

Python map() Function with Examples

Learn Python map() function with examples using custom functions, lambda, built-in functions, multiple iterables, string conversion, list conversion, and map vs list comprehension.

Bashir Alam6 min read
programming

Loop Through Two Lists in Python

Learn how to loop through two or more lists in Python using zip(), enumerate(), range(), indexes, nested loops, and zip_longest() for lists with different lengths.

Deepak Prasad8 min read
programming

Python Loop N Times: Repeat Code Using range()

Learn how to loop N times in Python using for range(), repeat code 5 or 10 times, loop without an index, use while loops, and avoid common off-by-one mistakes.

Deepak Prasad5 min read
programming

Python List pop() Method: Remove and Return Items

Learn how Python list pop() removes and returns items by index, defaults to the last item, handles pop(0), raises IndexError, and compares with remove(), del, and clear().

Bashir Alam9 min read
programming

Get File Extension in Python: pathlib, os.path, and edge cases

Learn how to get a file extension in Python using pathlib (suffix, suffixes), os.path.splitext, case-insensitive checks, multi-part names like .tar.gz, and common pitfalls.

Bashir Alam5 min read
programming

Install a Python Package from GitHub with pip: branches, tags, SSH, and requirements.txt

Install Python packages from GitHub using pip: PEP 508 git URLs, branches, tags, commits, editable installs, requirements.txt, private repos over HTTPS or SSH, subdirectory packages, verification, upgrades, and common …

Azka Iftikhar8 min read
programming

Python List with Examples

Learn Python lists with simple examples to create a list, access items, change values, add and remove elements, loop through lists, sort, copy, and use common list methods.

Deepak Prasad9 min read
programming

Python Line Continuation: Continue Code on the Next Line

Learn how Python line continuation works using parentheses, brackets, braces, and backslash, with examples for long expressions, strings, lists, function calls, and common errors.

Bashir Alam8 min read