How do you know you’re using the correct data structure for your Python project? There are so many built into Python and even more that are importable from the collections module. This week on the show, David Amos is back, and he’s brought another batch of PyCoder’s Weekly articles and projects. We discuss a recent three-part video course on selecting the ideal data structure.
Along with comparing the types of dictionaries, data records, arrays, stacks, and more, David covers a recent Real Python article about the namedtuple. This deep dive covers how to use the namedtuple to write cleaner code.
We also discuss new articles from previous guest Brett Cannon. He has added two posts to his Python syntactic sugar series about unravelling the pass
and with
statement.
We cover several other articles and projects from the Python community including, async in Flask 2.0, Python projects on Github that are examples of best practices and good architecture, how SpaceX sort of lands starship, the new ti-84 calculator with Python, and building a Python spell checker.
Spotlight: Stacks and Queues: Selecting the Ideal Data Structure
In this course, you’ll learn about three of Python’s data structures: stacks, queue and priority queues. You’ll look at multiple types and classes for all of these and learn which implementations are best for your specific use cases.
Topics:
Show Links:
Write Pythonic and Clean Code With namedtuple – In this step-by-step tutorial, you’ll learn what Python’s namedtuple is and how to use it in your code. You’ll also learn about the main differences between named tuples and other data structures, such as dictionaries, data classes, and typed named tuples.
Unravelling the pass Statement – When you need to indicate that a bit of code intentionally does nothing, then you need to reach for Python’s pass
statement. In the latest installment of Brett’s “Syntactic Sugar” series, you’ll learn how pass
works, when to use it, and why it’s a uniquely Python concept.
Unravelling the with statement
Async in Flask 2.0 – This article looks at Flask 2.0’s new async functionality and how to leverage it in your Flask projects. You’ll learn how Flask processes requests asynchronously using a traditional WSGI server, instead of the ASGI server used by many other async web frameworks. You’ll also learn how to simulate Flask 2.0 async in Flask 1.X applications.
Python Projects on Github That Are Examples of Best Practices and Good Architecture – This Reddit thread is full of GitHub repos that might make for some good code reading.
How SpaceX Lands Starship (Sort Of) – While waiting for SN15 to launch, Thomas Goddard set out to pull together a 2-dimensional simulation of the Starship landing. Tying together knowledge of trajectory optimization, Thomas modeled the landing in Python with the CasADI library and used Matplotlib to generate an animation which, when played side-by-side with the footage of the landing, results in remarkable similarity to the actual landing dynamics.
Stacks and Queues: Selecting the Ideal Data Structure – Learn about three of Python’s data structures: stacks, queue and priority queues. You’ll look at multiple types and classes for all of these and learn which implementations are best for your specific use cases.
Projects:
Additional Links:
Level up your Python skills with our expert-led courses: