//
sign in
Profile
by @danabra.mov
Profile
by @dansshadow.bsky.social
Profile
by @jimpick.com
AviHandle
by @danabra.mov
AviHandle
by @dansshadow.bsky.social
AviHandle
by @katherine.computer
EventsList
by @katherine.computer
ProfileHeader
by @dansshadow.bsky.social
ProfileHeader
by @danabra.mov
ProfileMedia
by @danabra.mov
ProfilePlays
by @danabra.mov
ProfilePosts
by @danabra.mov
ProfilePosts
by @dansshadow.bsky.social
ProfileReplies
by @danabra.mov
Record
by @atsui.org
Skircle
by @danabra.mov
StreamPlacePlaylist
by @katherine.computer
+ new component
Profile
Trey Hunner
Python & Django team trainer I help folks sharpen their Python skills with https://PythonMorsels.com 🐍πŸͺ YIMBY. 95% vegan.
Loading...








Loading...
New screencast on stack-like and queue-like operations in Python. Lists are great for one of these and not so great for the other.
7h
Trey Hunner
πŸ—ΊοΈ June 10, 2026 5/5 countries in 6/13 guesses 🟒🟒🟒🟑🟒 whereabouts.earth/daily/ #Whereabouts
πŸ—ΊοΈ June 9, 2026 5/5 countries in 5/13 guesses 🟒🟒🟒🟒🟒 whereabouts.earth/daily/ #Whereabouts The rivers helped me a lot today
You don't need to replace ALL your lists with deques. Lists are still the right default: they're great for indexing, slicing, and stack-like operations. But if you find yourself frequently adding or removing items from the beginning, a deque is a better fit than a list.
To remove a prefix or suffix, use the removeprefix or removesuffix methods. Read more πŸ‘‰ https://trey.io/dley4p #Python
Python Tip #160 (of 365): Using list.insert(0, ...)? Consider using a deque instead. 🧡 Inserting at the beginning of a list is slow because every existing item needs to be shuffled over. This takes seconds: nums = [] for n in range(200_000): nums.insert(0, n) #Python #DailyPythonTip
β€œGenerator expressions also pair nicely with reducer functions.” Read more πŸ‘‰ pym.dev/custom-compr... #Python
8h
1d
1d
But this runs nearly instantly: from collections import deque numbers = deque() for n in range(200_000): numbers.appendleft(n) A deque (short for "double-ended queue") is optimized for both ends. It has appendleft and popleft in addition to the usual append and pop.
1d
1d
1d
Use a Python list for stack operations (last-in, first-out) and a deque from the collections module for queue operations (first-in, first-out).
pym.dev
Stacks and queues in Python
1d
β€œSo the next time you need to split a string into lines, don't use the string split method.” Read more πŸ‘‰ pym.dev/splitlines/ #Python
Trey Hunner
Trey Hunner
Trey Hunner
Trey Hunner
Trey Hunner
1d
Trey Hunner
Trey Hunner
Trey Hunner
Whereabouts Daily
How many of today's five countries can you guess?
whereabouts.earth