@teachmepython.bsky.social
+ Follow
240
followers
130
following
400
posts
Posts
Media
Videos
Starter Packs
teachmepython.bsky.social
@teachmepython.bsky.social
· 14h
Install the latest
#Python
today with uv:
uv python upgrade 3.14
1
teachmepython.bsky.social
@teachmepython.bsky.social
· 19h
#Python
Tricks
Want to read the Python code of the file you are executing?
Add the following to the end of your script and it will output the entire file to stdout:
1
teachmepython.bsky.social
@teachmepython.bsky.social
· 1d
#Python
3.14 is out now!
🐍 - Free-threading
🐍 - Deferred annotations
🐍 - t-strings
🐍 - ZStandard compression
🐍 - Multi-interpreter support
🐍 - JIT compiler included for Windows and MacOS
🐍 - and more!
1
1
teachmepython.bsky.social
@teachmepython.bsky.social
· 1d
#Python
Pop Quiz 🐍❓
What is the output of the following code?
A) Syntax Error
B) Type Error
C) Case A Found!
D)
1
teachmepython.bsky.social
@teachmepython.bsky.social
· 2d
Need to find the most common number in a sequence with
#Python
? 🐍🔥
The collections module has a great class for that!
1
teachmepython.bsky.social
@teachmepython.bsky.social
· 6d
#Python
Pro Tip - How to flatten a list of lists 🐍🔥
1
teachmepython.bsky.social
@teachmepython.bsky.social
· 7d
Stupid
#Python
trick 🐍🤯
Calling a dunder method directly without using name mangling
teachmepython.bsky.social
@teachmepython.bsky.social
· 9d
#Python
Pop Quic 🐍❓
A) {range}
B) (range)
C) [0, 1, 2]
D) (0, 1, 2)
E) {0, 1, 2}
1
teachmepython.bsky.social
@teachmepython.bsky.social
· 9d
I don't use lambdas very often, but they are very handy in
#Python
when you use the built-in sorted() function
By using a lambda, you can do some cool advanced sorting! 🐍🔥
1
1
6
teachmepython.bsky.social
@teachmepython.bsky.social
· 13d
What have you used
#Python
's case statement for? 🐍❓
If you haven't seen it, here's an example:
teachmepython.bsky.social
@teachmepython.bsky.social
· 13d
#Python
Pop Quiz 🐍❓
What will be the output if you run this code?
A) Outer ZeroDivisionError exception caught
B) Error: You divided by zero!
C) Error: You divided by zero! Finally executed
D) Finally executed
E) None of the above
teachmepython.bsky.social
@teachmepython.bsky.social
· 14d
Need to time how long a short snippet of
#python
code takes to run? Use the timeit module! 🐍🔥
You can also use timeit to time functions and imports!
teachmepython.bsky.social
@teachmepython.bsky.social
· 14d
Here's a silly example of a function factory using
#Python
and lambdas
Normally, you wouldn't use lambdas, but you might have a list of functions or a use a generator to return functions or callables.
teachmepython.bsky.social
@teachmepython.bsky.social
· 19d
Here's some ternary fun with
#Python
🐍🔥
1
teachmepython.bsky.social
@teachmepython.bsky.social
· 19d
How to use
#Python
threads to target specific functions as workers
teachmepython.bsky.social
@teachmepython.bsky.social
· 19d
How often do you use the ternary operator in
#Python
?
Here's an example in case you haven't heard of it:
teachmepython.bsky.social
@teachmepython.bsky.social
· 20d
Have you ever used a generator expression in
#Python
? They are similar to a list comprehension except that you get a generator returned.
Check it out:
2
teachmepython.bsky.social
@teachmepython.bsky.social
· 21d
Function overloading in
#Python
using the functools module! 🐍🔥
teachmepython.bsky.social
@teachmepython.bsky.social
· 22d
You can read his whole write-up here:
benkurtovic.com/2014/06/01/...
teachmepython.bsky.social
@teachmepython.bsky.social
· 22d
One of the craziest lambdas I have ever seen in
#Python
🐍🚀
The obfuscated "Hello World" by Ben Kurtovic
1
1
teachmepython.bsky.social
@teachmepython.bsky.social
· 22d
Have you ever used
#Python
's handy ChainMap collection?
You can use ChainMap to combine dictionaries, among other things:
3
teachmepython.bsky.social
@teachmepython.bsky.social
· 22d
Here's a silly
#Python
trick. 🐍🔥
You can use lambdas to create a simple function dictionary where you can call each function using the key in the dict:
teachmepython.bsky.social
@teachmepython.bsky.social
· 26d
You can get the GitKracken Pro subscription for 50% off here:
gitkraken.cello.so/DnismeH8TmN
GitKraken Legendary Git Tools | GitKraken
Meet GitKraken, the creator of legendary Git tools for developers and teams - like the GitKraken Desktop, with Git GUI and CLI, Git Integration for Jira, and GitLens for VS Code.
gitkraken.cello.so
teachmepython.bsky.social
@teachmepython.bsky.social
· 26d
GitKracken gave me a 50% off GitKracken Pro subscription link.
I've been using GitKracken for a few years now and find it really useful, especially with complex merges or working with large teams.
1
1
teachmepython.bsky.social
@teachmepython.bsky.social
· Sep 4
You can listen and subscribe here:
www.pythonshow.com/p/55-the-py...
55 - The Python Documentary with Paul Everitt
In this episode, we have special guest Paul Everitt on the show to talk about the new Python Documentary that came our last week.
www.pythonshow.com