Python Peak

@PythonPeak
15 Followers
0 Following
253 Posts
Quick Python chats, ideas, and tips to level up your coding

What's wrong with this Python streaming response?

What's wrong with this Python streaming response in an API. The Python code closes the database cursor before the generator is consumed, so the stream fails mid response. In Python services this causes partial downloads.

#whatswrongwiththispythoncode #pythonbug #pythonproductionbug #pythondebugging #pythonbackend #pythoncodereview #pythonmistake #pythonbestpractices #pythonreliability #pythonincid...

https://www.youtube.com/watch?v=MqjVyD53Uic

Whats wrong with this Python streaming response? #pythondataloss

YouTube

Why does this Python asyncio task run on wrong loop?

Why does this Python asyncio task run on wrong loop in a multi-loop app. The Python code creates a task from a thread without passing the loop. In Python services this schedules on the wrong event loop.

#whatswrongwiththispythoncode #pythonbug #pythonproductionbug #pythondebugging #pythonbackend #pythoncodereview #pythonmistake #pythonbestpractices #pythonreliability #pythonincident #pythonapi ...

https://www.youtube.com/watch?v=1_tED3YnL-8

Why does this Python asyncio task run on wrong loop? #whatswrongwiththispythoncode

YouTube

How to Stop dict.fromkeys From Sharing Lists

fromkeys can point every key to the same list.

#python #dictfromkeys #sharedstate #bug #howto #lists

https://www.youtube.com/watch?v=UA72HQuTLP0

How to Stop dict.fromkeys From Sharing Lists #bug

YouTube

Web Network Vertical

8 rings with 24 spokes create a massive spider web! Python weaves this intricate network pattern! 🕸️✨

#python #pythontricks #turtlegraphics #spiderweb #radialpattern #webnetwork #concentricrings #spokespattern #naturegeometry #pythoncircles #symmetricalweb #networkstructure

https://www.youtube.com/watch?v=-fxnRdWdsKk

Web Network Vertical #concentricrings

YouTube

How to Create a Dict From Two Lists Instantly

dict(zip(keys, vals)). One line. No loop. Most forget this.

#python #dict #zip #oneline #howto

https://www.youtube.com/watch?v=ZJnpgxi4cNw

How to Create a Dict From Two Lists Instantly #zip

YouTube

What's wrong with this Python cache read?

What's wrong with this Python cache read in a quota service. The Python code treats falsey values as a cache miss, so real zeros keep hitting the database. In production Python APIs this explodes traffic and latency when quotas are exhausted.

#whatswrongwiththispythoncode #pythonbug #pythonproductionbug #pythondebugging #pythonbackend #pythoncodereview #pythonmistake #pythonbestpractices #pythonreliabilit...

https://www.youtube.com/watch?v=e2xIU-tgPH4

Whats wrong with this Python cache read? #whatswrongwiththispythoncode

YouTube

Array Slicing: Python's [::-1] vs PHP Functions!

Python's magical slice syntax vs PHP's functions! arr[::-1] to reverse?! Which is cleaner? MIND BLOWN!

#python #php #pythonvsphp #arrayslicing #slicesyntax #arrayoperations #codecomparison #syntaxcomparison #pythontricks #phptricks #programmingdebate #codingtips #pythonmagic #arrayfunctions

https://www.youtube.com/watch?v=N2t3ureX7QQ

Array Slicing: Pythons ::-1 vs PHP Functions! #PHP

YouTube

'in' Operator: Python's ONE vs PHP's MANY Functions!

Python's 'in' works for EVERYTHING! PHP needs in_array, str_contains, array_key_exists... Which is better?!

#python #php #pythonvsphp #inoperator #inarray #strcontains #membershiptest #codecomparison #pythontricks #phptricks #programmingdebate #codingtips #pythonsyntax #phpfunctions

https://www.youtube.com/watch?v=WIU7E-gUPY4

in Operator: Pythons ONE vs PHPs MANY Functions! #membershiptest

YouTube

Python Abstract Base Classes

Abstract Base Classes for defining interfaces
Using ABC to enforce method implementation

#python #programming #tutorial #coding #abstract #base #classes

https://www.youtube.com/watch?v=yAGn_zltCX4

Python Abstract Base Classes #base

YouTube

How to Stop Forgetting the else in Loop

for-else runs when no break. Find-first pattern. Miss it = subtle bug.

#python #forelse #break #find #howto

https://www.youtube.com/watch?v=FlqjgYc2O4A

How to Stop Forgetting the else in Loop #howto

YouTube