Articles by Bashir Alam
Python *args and **kwargs
Learn Python *args and **kwargs with simple examples. Understand positional arguments, keyword arguments, how to iterate over kwargs, and how to pass args and kwargs to another function.
Python Join List
Learn how to join a list in Python using str.join(), including lists of strings, numbers, mixed values, separators, newline joins, and common TypeError fixes.
Python isupper() Method
Learn Python isupper() method with examples. Check if a string is uppercase, understand return values for numbers, symbols, spaces, empty strings, and compare isupper() with upper(), islower(), and isalpha().
Python Get Home Directory
Learn how to get the current user's home directory in Python using pathlib Path.home(), os.path.expanduser('~'), and environment variables like HOME and USERPROFILE.
Python filter() Function
Learn Python filter() function with simple examples. Filter lists, strings, dictionaries, and objects using normal functions, lambda functions, filter(None), and list comprehension alternatives.
Python for Loop in One Line
Learn how to write a Python for loop in one line using list comprehension, generator expressions, for with if condition, if else expression, and simple inline loop examples.
Python Flatten List
Learn how to flatten a list of lists in Python using list comprehension, itertools.chain.from_iterable, nested loops, recursion for deep nesting, and NumPy, plus when to avoid sum() on large data.
Python ceil() Function
Learn Python ceil() using math.ceil() with examples for positive and negative numbers, ceiling division, ceil vs floor, integers, floats, and common mistakes.
Python Class Example
Learn Python classes with simple examples to create a class, create objects, use __init__ and self, define attributes and methods, class variables, inheritance, and common mistakes.
Get Size of Priority Queue in Python: qsize, empty, and maxsize
Learn how to get the size of a Python PriorityQueue with qsize(), compare it to empty() and full(), understand approximate counts under threads, and relate current size to maxsize.
Python Delete File
Learn how to delete a file in Python using pathlib Path.unlink(), os.remove(), and os.unlink(), including delete-if-exists examples, error handling, and deleting all files in a folder.
Python property deleter
Learn how Python property deleter works with @property, @name.setter, and @name.deleter, including how del obj.attr calls the deleter method and common mistakes.
Python Exit Program
Learn how to exit a Python program or script using sys.exit(), exit(), quit(), return, and break, including exit codes, messages, functions, loops, and common mistakes.
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.
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.
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.
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.
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.
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.
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.
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().
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.
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.
Python Marshmallow Tutorial: Schema, Fields, dump(), and load()
Learn Python Marshmallow with examples for creating schemas, using fields, serializing data with dump(), deserializing and validating data with load(), nested schemas, many=True, DateTime formatting, and common errors.
Nested Dictionary in Python: Create, Access, Update, and Loop
Learn nested dictionaries in Python with examples to create, access, update, add, delete, loop through, flatten, and merge dictionary inside dictionary data.
Python Lambda & Anonymous Functions: Syntax, Examples, map(), filter(), sorted()
Learn Python lambda functions (anonymous functions): syntax, examples with multiple arguments, map(), filter(), sorted(), conditional expressions, limits, common mistakes, and when to use def instead.
Python any() and all() Functions: Check If Any or All Items Are True
Learn how Python any() and all() work with lists, strings, dictionaries, truthy and falsy values, generator expressions, short-circuiting, and common mistakes.
How to Concatenate Tensors in PyTorch: torch.cat, stack, and shapes
Learn how to concatenate tensors in PyTorch with torch.cat along dim 0 or 1, torch.concat and torch.concatenate aliases, shape rules, stack vs cat, device errors, and a quick reference table.
Python floor() Function Explained (math.floor, Examples, vs int & round)
Learn how to use floor() in Python with practical examples. Understand math.floor(), differences between floor vs int vs round, handling negative numbers, Pandas and NumPy usage, and common errors. Includes syntax, …
Java Arrays vs Collections Explained with Practical Examples
Learn the differences between arrays and collections in Java with practical examples. This guide explains how to create arrays, initialize lists, print arrays, determine collection size, and work with common Java …

