Python Snacks logo
Python Snacks
AdvertiseContact
Subscribe
  • Python Snacks
  • Topics
  • control flow

control flow

Conditionals, loops, match/case, flow modifiers.

best-practicescomparisongeneratorscareertype hintspythonic thinkingbeginnerdecoratorsreferencedocumentationconcurrencymetaprogrammingdata analysisfunctionscheat sheetdata structuresartificial intelligencetool-reviewadvancedwebsecurityOne-Offssnippettoolingworkflowstandard librarybreakdownpackagechecklisttemplateintermediateclicase-studyquick winpackagingasynccontrol flowgotchasoopdeep diveperformance
snippetsnippet
+2+2
Faster String Slicing in NumPy
Jul 02, 2025

Faster String Slicing in NumPy

A new vectorized approach to slicing string arrays in NumPy, shown to be up to 25x faster!

Hamna Rashid
Hamna Rashid
beginnerbeginner
+2+2
Python's match/case Statements: The Equivalent of Switch Statements
Jun 04, 2025

Python's match/case Statements: The Equivalent of Switch Statements

This feature, used in Python 3.10+, is an alternative to if/elif/else blocks. See how case and match statements are used.

Brandon Molyneaux
Brandon Molyneaux
comparisoncomparison
+2+2
The Simplest Way to Understand The Difference Between For Loops and While Loops
Mar 12, 2025

The Simplest Way to Understand The Difference Between For Loops and While Loops

There's a major difference between for and while loops, and this explanation hits the key difference.

Brandon Molyneaux
Brandon Molyneaux
beginnerbeginner
+2+2
Python except: The Danger of Overgeneralizing Exceptions
Jan 22, 2025

Python except: The Danger of Overgeneralizing Exceptions

How catching every exception with ‘except’ in Python can break your code and hide critical errors.

Brandon Molyneaux
Brandon Molyneaux
beginnerbeginner
+3+3
Writing Faster Code: 7 Simple Ways to Improve Your Python Loops
Sep 26, 2024

Writing Faster Code: 7 Simple Ways to Improve Your Python Loops

Practical tips to speed up your Python code and make your loops more efficient.

Brandon Molyneaux
Brandon Molyneaux
beginnerbeginner
+2+2
Understanding Python's finally statement
Aug 28, 2024

Understanding Python's finally statement

This is a control flow tool you should've learned yesterday.

Brandon Molyneaux
Brandon Molyneaux
beginnerbeginner
+2+2
A quick tutorial for the for/else construct in Python
Aug 22, 2024

A quick tutorial for the for/else construct in Python

Here's how you're able to use this and why sometimes it's more adventageous

Brandon Molyneaux
Brandon Molyneaux
comparisoncomparison
+2+2
Comparing Python's for and while loops
Aug 14, 2024

Comparing Python's for and while loops

Here's when you should use one over the other

Brandon Molyneaux
Brandon Molyneaux
referencereference
+2+2
Itertools: The One Package to Not Look Over
Jul 17, 2024

Itertools: The One Package to Not Look Over

Here's how you can leverage Python's itertools library to be more efficient with your looping

Brandon Molyneaux
Brandon Molyneaux
advancedadvanced
+2+2
Understanding Python’s Walrus Operator (:=) for Efficient Code
Dec 20, 2023

Understanding Python’s Walrus Operator (:=) for Efficient Code

Writing Cleaner, More Efficient Python Code with the Walrus Operator

Brandon Molyneaux
Brandon Molyneaux
Become a better software engineer with Python.

Python Snacks

Become a better software engineer with Python.

Home

Posts

Authors

Account

Upgrade

Advertise

Advertise

© 2025 Python Snacks.

Privacy policy

Terms of use

Powered by beehiiv