The Python walrus operator (:=) assigns a value to a variable and returns that value in the same expression — no separate line, no repeated function call. It was introduced in Python 3.8 via PEP 572, and the patterns where it earns its place go well beyond the basics: — While loops that read from files or sockets without duplicating the call — List comprehension filters that run an expensive function once, not twice — Regex conditionals where the match object is available immediately — Generator pipelines that transform, filter, and bind in a single pass — Database cursor streaming without loading the full result set into memory — Retry loops with exponential backoff where the response binds on success The tutorial linked below also covers the governance history — PEP 572 is the only Python proposal that led directly to Guido van Rossum stepping down as BDFL, which produced the Steering Council model still in use today. Includes quizzes, spot-the-bug challenges, a code builder, and a final exam with a downloadable certificate of completion upon passing the final exam with a minimum score of 80%. https://lnkd.in/g2r9UX55 #Python #PythonProgramming #LearnPython #PEP572 #SoftwareDevelopment #Programming #CodingTips
Kandi Brian’s Post
More Relevant Posts
-
Python has four types of comprehensions — and most beginners only learn one. List comprehensions get all the attention. But dictionary comprehensions, set comprehensions, and generator expressions follow the same pattern and solve problems lists can't. The new tutorial on PythonCodeCrack covers all four from scratch: — List comprehensions: what they are, how they compare to a for loop, and how CPython optimizes them at the bytecode level — Dictionary comprehensions: inverting dicts, filtering by value, building lookup tables with zip() — Set comprehensions: automatic deduplication, when to reach for them over a list — Generator expressions: lazy evaluation, the iterator protocol, and when memory actually matters Also covered: the walrus operator inside comprehensions, Python 3 scoping rules, nested comprehensions and when to avoid them, duplicate key behavior in dict comprehensions, and the difference between an if filter and an if-else expression. Includes interactive code builders, spot-the-bug challenges, a quiz, and a final exam with a downloadable certificate of completion. Full tutorial: https://lnkd.in/gNCskxTD #Python #PythonProgramming #LearnPython #PythonTips #Programming #SoftwareDevelopment
To view or add a comment, sign in
-
Some python list tutorials stop at my_list.append(x). That is the surface. Underneath, a list is a C struct called PyListObject holding an array of pointers to PyObject instances. The list does not store your data. It stores references to wherever your data lives on the heap. That single fact is the root cause of the aliasing bugs that catch developers off guard. A few things that land differently once you understand the memory model: Why append() is O(1) amortized. CPython over-allocates on resize using the growth sequence 0, 4, 8, 16, 24, 32, 40, 52, 64, 76... so the O(n) copy cost spreads across many appends. Why b = a and then mutating b also mutates a. They are two names pointing at the same PyListObject. Why list.sort() runs in O(n) on nearly-sorted data. Timsort, written by Tim Peters in 2002, finds already-sorted runs and merges them. Stability has been a documented guarantee since Python 2.2. Why list.pop() from the end is O(1) but list.pop(0) is O(n). Elements after the index have to shift. I put together an 11-tutorial learning path on PythonCodeCrack that walks through lists from first principles through the copy semantics and aliasing patterns that cause hard-to-trace bugs. Fundamentals first (creation, slicing, append vs extend, sorting, comprehensions), then the advanced group (flattening, shallow vs deep copy, why your list keeps changing unexpectedly). https://lnkd.in/g5uUXj6d #Python #SoftwareEngineering #CPython #Programming
To view or add a comment, sign in
-
Python functions with fixed signatures break the moment you need to forward arguments across abstraction boundaries. *args and **kwargs solve that — and this python tutorial goes well past the syntax. — How CPython actually handles variadic calls at the C level (PyTupleObject, PyDictObject, and why there's a real allocation cost) — Why a defaulted parameter before *args is effectively unreachable via positional calling — and the idiomatic fix — The difference between *args isolating the mapping vs sharing mutable values inside it — ParamSpec (PEP 612) for preserving decorator signatures through the type system — TypedDict + Unpack (PEP 692, Python 3.12) for per-key precision on **kwargs — inspect.Parameter.kind for reading variadic signatures at runtime — the foundation of FastAPI and pytest's dispatch logic — Lambda variadic syntax, functools.wraps, kwargs.setdefault patterns, and common SyntaxErrors caught at parse time Includes interactive quizzes, spot-the-bug challenges, a design decision review, and a 15-question final exam with a downloadable certificate of completion. Full guide: https://lnkd.in/gHkdvCn5 #Python #PythonProgramming #SoftwareDevelopment
To view or add a comment, sign in
-
If you have ever tried to test a Python class and realized the test required spinning up a real database, you have already felt tight coupling — even if you did not have a name for it. Tight coupling happens when one class creates another inside its own constructor. That one design choice locks the two classes together, blocks substitution in tests, and causes changes to ripple across the codebase in ways that are hard to trace. The core fix is a single constructor change: accept the dependency as a parameter instead of building it internally. From there, typing.Protocol lets you depend on a contract rather than a concrete class, so any object with the right methods can be passed in without inheritance. The tight coupling tutorial on PythonCodeCrack covers every major form tight coupling takes in Python: hard-wired constructors, inheritance used as a shortcut for code reuse, global state that hides dependencies, and temporal coupling — the kind where two method calls must happen in a specific order but nothing in the interface communicates that. It also covers where loose coupling goes too far, when tight coupling is the correct choice, and how to refactor existing coupled code incrementally without breaking call sites. Complete the final exam to earn a certificate of completion — shareable with your network, current employer, or prospective employers as proof of your continuing Python programming education. https://lnkd.in/gq98uPPm #Python #SoftwareDesign #DependencyInjection
To view or add a comment, sign in
-
List comprehensions are one of those Python features that look intimidating at first and then become second nature fast. New tutorial on PythonCodeCrack walks through everything from the ground up: — The three-part syntax and what each part does — How a comprehension maps to an equivalent for loop — Adding filter conditions — Using enumerate() and zip() as source iterables — Ternary expressions vs. filter conditions (a common point of confusion) — When not to use a comprehension — How CPython executes them differently from for loops, including what changed in Python 3.12 — Dict and set comprehensions Includes an interactive syntax visualizer, step tracer, spot-the-bug challenges, quizzes, and a final exam with a certificate of completion. https://lnkd.in/g6VisquH #python #FreeCertificationCourse #tutorials
To view or add a comment, sign in
-
🐍 Python has had frozenset for decades. Python may soon have frozendict The key nuance: frozendict is not part of a stable Python release yet. It is targeted for Python 3.15 and is available in preview builds for testing. Treat it as an upcoming feature, not something already shipped in production. Here’s why it matters ⚙️ Regular dictionaries in Python are mutable. You can add keys, reassign values, and remove items at any time. They are also unhashable, which means they cannot be used as keys in other dictionaries or stored in sets. In addition, like all mutable objects, they can be modified when passed into functions that receive them, which can make it harder to guarantee that data remains unchanged. frozendict addresses a long-standing need in the Python ecosystem for an immutable, hashable mapping type. 🔧 What it provides → Hashable - can be used as a dictionary key or stored in a set → Immutable - attempts to modify raise an exception at runtime → Preserves insertion order 💡 What this enables → Configuration objects that cannot be accidentally modified → Cache keys that require stable hashing → Safer data sharing between components → Functional-style patterns without defensive copying If you are using Python 3.15 preview builds, you can experiment with it today config = frozendict(api_version="v2", timeout=30, retries=3) # config["timeout"] = 10 → TypeError More information 👉 https://shorturl.at/g4IE6 #Python #Python3 #Python315 #Programming #ProgrammingLanguages #SoftwareEngineering #SoftwareDevelopment #BackendDevelopment #DevOps #CleanCode #SystemDesign #CodeQuality #ComputerScience #DevTactics #Developer #Programmer
To view or add a comment, sign in
-
-
Headline: Python is evolving. Are you? 🐍 I published a quick guide on the "Modern Python Trinity" that every dev should be using in 2026: ✅ The Walrus (:=) – Clean up your loops. ✅ Match-Case – Destroy those nested if-elif chains. ✅ Parenthesized Ctx Managers – No more messy backslashes (\). #Python #CleanCode #Programming #SoftwareDevelopment #Tips
To view or add a comment, sign in
-
🐍📰 Gemini CLI vs Claude Code: Which to Choose for Python Tasks Gemini CLI vs Claude Code: compare setup, performance, code quality, and cost to find the right Python AI coding tool for your workflow https://lnkd.in/gGAXv_ph
To view or add a comment, sign in
-
Build a RAG pipeline from scratch in Python without LangChain Learn to build a RAG pipeline in Python from scratch using ChromaDB and OpenAI embeddings — no LangChain required. Read the full post 👇 https://lnkd.in/gBHKATvy #GenerativeAI #AI #WebDevelopment #PHP #Python #Developer #LLM
To view or add a comment, sign in
Explore related topics
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development