Tagged articles
8 articles
Page 1 of 1
Python Programming Learning Circle
Python Programming Learning Circle
Jul 5, 2022 · Fundamentals

12 Essential Python Code Snippets for Everyday Programming

This article presents twelve practical Python code snippets—including regular‑expression validation, list slicing, swapping without a temporary variable, f‑strings, dictionary inversion, multithreading, most‑common element detection, CSV parsing, and more—to help developers write concise, efficient code without lengthy boilerplate.

CSVcode snippetslist slicing
0 likes · 9 min read
12 Essential Python Code Snippets for Everyday Programming
MaGe Linux Operations
MaGe Linux Operations
Jun 3, 2019 · Fundamentals

7 Common Python Pitfalls Explained with Code Examples

This article walks through seven tricky Python snippets—default mutable arguments, lambda closures, class variable inheritance, division differences between Python 2 and 3, out‑of‑range slicing, list multiplication side effects, selective list comprehensions, and custom dict subclasses—explaining their outputs and how to fix them.

Class Variablesclosuresdefault-arguments
0 likes · 12 min read
7 Common Python Pitfalls Explained with Code Examples
MaGe Linux Operations
MaGe Linux Operations
Nov 1, 2018 · Fundamentals

Master Python Defaults, Closures, and Class Variables: Common Pitfalls Explained

This article explains why mutable default arguments share state, how Python closures cause late binding issues, the inheritance rules of class variables, differences between division operators in Python 2 and 3, list slicing behavior, list multiplication references, list comprehensions for even-indexed values, and custom dict subclasses with __missing__.

Class VariablesPythonclosures
0 likes · 11 min read
Master Python Defaults, Closures, and Class Variables: Common Pitfalls Explained
MaGe Linux Operations
MaGe Linux Operations
Oct 27, 2017 · Fundamentals

Common Python Gotchas: Default Arguments, Closures, and Class Variables Explained

This article walks through several classic Python pitfalls—including mutable default arguments, closure late binding, class variable inheritance, division operator differences between Python 2 and 3, list slicing edge cases, shared references in list multiplication, list comprehensions for even-indexed values, and custom dict subclasses—explaining why they occur and how to fix them.

Pythonlist slicing
0 likes · 12 min read
Common Python Gotchas: Default Arguments, Closures, and Class Variables Explained