@teachmepython.bsky.social
π€ 242
π₯ 132
π 390
#Python
Pop Quic πβ A) {range} B) (range) C) [0, 1, 2] D) (0, 1, 2) E) {0, 1, 2}
1 day ago
1
0
0
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 day ago
1
6
1
What have you used
#Python
's case statement for? πβ If you haven't seen it, here's an example:
5 days ago
0
0
0
#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
5 days ago
0
0
0
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!
6 days ago
0
0
0
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.
6 days ago
0
0
0
Here's some ternary fun with
#Python
ππ₯
10 days ago
0
1
0
How to use
#Python
threads to target specific functions as workers
11 days ago
0
0
0
How often do you use the ternary operator in
#Python
? Here's an example in case you haven't heard of it:
11 days ago
0
0
0
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:
12 days ago
0
2
0
Function overloading in
#Python
using the functools module! ππ₯
13 days ago
0
0
0
One of the craziest lambdas I have ever seen in
#Python
ππ The obfuscated "Hello World" by Ben Kurtovic
13 days ago
1
1
0
Have you ever used
#Python
's handy ChainMap collection? You can use ChainMap to combine dictionaries, among other things:
14 days ago
0
3
0
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:
14 days ago
0
0
0
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.
18 days ago
1
1
0
The latest episode of The Python Show Podcast is out now! Listen in as I chat with Paul Everitt about the beginnings of the
#Python
language, the new Python documentary, and much more!
26 days ago
1
0
0
One way to annotate a plot in
#Python
using matplotlib
29 days ago
0
0
0
Did you know that
#Python
has arrays? No, I am not talking about lists. I'm talking about the array module:
about 1 month ago
1
4
0
How to convert a CSV file to Excel using Python and pandas ππΌ
about 1 month ago
0
1
0
How to create a simple PDF with
#Python
and the borb package ππ₯
about 1 month ago
0
3
0
How to profile code with
#Python
using the built-in cProfile module in the REPL
about 1 month ago
0
1
0
The latest episode of The Python Show is out now! Today's special guest is Nicolas Rougier who researches the brain using neural networks with
#Python
about 1 month ago
1
1
0
Need to create a thread pool in
#Python
? ππ₯ Here's one way to do that using Python'se handy concurrent futures library:
about 1 month ago
0
1
0
Here are a couple of different ways to create an empty function or stub in
#Python
This can be useful when planning your code or presenting to your team how something could be implemented.
about 1 month ago
0
0
0
#Python
Pop Quiz πβ What is the output of the following code? A) 255 B) 256 C) ff D) 377
about 1 month ago
0
0
0
How to reverse a string and a list in
#Python
using slicing! ππ₯
about 1 month ago
0
1
0
Which
#Python
CLI tool(s) do you use and why? π argparse π click π cyclopts π Typer π Rich π python-fire
about 1 month ago
1
2
0
#Python
Pop Quiz πβ What is the output of the following code? A) {1, 2, 3} B) 1, 2, 3 C) (1, 2, 3) D) An exception is raised
about 1 month ago
0
2
0
#Python
Pop Quiz πβ What is the output of the following code? A) {[4,5,6]} B) 4, 5, 6 C) [4, 5, 6] D) [4,5,6]
about 1 month ago
0
2
0
#Python
Pop Quiz πβ What is the output of the following code? A) Syntax Error B) ... C) Ellipsis D) None of the above
about 1 month ago
0
1
0
#Python
Pop Quiz πβ What is the length that is returned? A) 0 B) 1 C) 2 D) None of the above
about 2 months ago
0
2
0
#Python
Pop Quiz πβ What is the output of the following code? A) AttributeError B) 10 C) 14 D) 7
about 2 months ago
0
0
0
#Python
Pop Quiz πβ What is the output of the following code? A) a ['b', 'c'] B) ['a', 'b', 'c'] C) ['b', 'c'] D) None of the above
about 2 months ago
0
0
0
#Python
101 - How to read a TOML file using a `pathlib.Path` object
about 2 months ago
0
1
0
#Python
Pro Tip π If you use the uv package manager, don't forget to clean up every so often. You may end free up gigabytes of data on your hard drive!
about 2 months ago
0
0
0
The latest edition of the Python Papers Newsletter is out now! Learn how to read a TOML document with
#Python
using the standard library! ππ₯
about 2 months ago
1
1
0
#Python
Pop Quiz πβ What is the output of the following REPL session?
2 months ago
0
1
0
Want to sort a dictionary by value in
#Python
? Here's one way to do that using the handy built-in sorted() function:
2 months ago
0
0
0
Did you know that
#Python
for loops had an optional `else` statement? If you don't break out of the loop, the `else` statement executes. Here are two examples, one that loops through without breaking and one that does:
2 months ago
0
2
0
Yesterday, I showed how to change a single pixel in an image with OpenCV and
#Python
ππ₯ But what if you wanted to change multiple pixels all at once? Well, you don't need a loop. You can set a range of rows and columns. Here's how:
2 months ago
0
0
0
#Python
Pop Quiz πβ What is the output of this code? A) [15] B) [] C) [1, 2, 3, 15] D) [1, 2, 3] E) An error is raised
2 months ago
1
0
0
How to change a single pixel's value using OpenCV and
#Python
2 months ago
0
0
0
Hereβs a new way to bring real production behavior into your IDE - itβs called Hud. Hud dynamically and automatically gathers unique live service and function-level data straight from production
2 months ago
1
0
0
You can unpack lists, tuples and ranges in
#Python
using the helpful asterisk!
2 months ago
0
1
0
#Python
Pro Tip Use the unpacking operator to help you create new dictionaries
2 months ago
0
0
0
π
#Python
Pro Tip Use generator expessions for memory efficiency and lazy evaluation Regular generators are also great for working with large data sets!
2 months ago
0
2
0
How to create a blank Excel spreadsheet with
#Python
and OpenPyXL with only FOUR lines of code! ππ
3 months ago
0
1
0
#Python
Pop Quiz πβ Which of the following values is no longer true when you check its identity in the Python REPL?
3 months ago
0
0
0
#Python
Pop Quiz πβ What is the output of the following code? A) [[True]. [True], [True]] B) [[10], [10], [10]] C) [[True], [False], [5]] D) [[False], [False], [False]]
3 months ago
0
0
0
There are 3οΈβ£ ways to remove items from a
#Python
dictionary. Let's talk about them today! ππ§΅π
3 months ago
1
0
0
Load more
feeds!
log in