+10 CRAZY Ways To FORMAT Text In Python with F-Strings

preview_player
Показать описание
Python's F-Strings are far more powerful than you think! Here are +10 ways that you can format text in Python with F-Strings. Do you know all of them?

▶ Become job-ready with Python:

▶ Follow me on Instagram:
Рекомендации по теме
Комментарии
Автор

The = Can be uset to print both variable names and their value.
print(f"{foo=} {bar=}") - will print “foo= 1 bar= 2”.
Useful for quick debugging.

Martin-delta
Автор

Thanks! I was looking for something like this just a day ago.

tuzaguilar
Автор

This is VERY cool and handy info. I'm fairly new to coding in Python but I can already see some users for this.

FreihEitner
Автор

1. Reduce amount of decimals is not the best word in that case, cause the number will be just rounded not cut off ;)
2. Recently, I've discovered, that it is possible to add own format to class via __format__ magic method ;) And then it can be used in fstring for example

grzegorzryznar
Автор

That's why you need to read the manual for anything you buy

cirklare
Автор

Thank you for this video, it is very helpful

yaseralhalaby
Автор

Something I like, when defining your own classes, is that whatever you write after the : (e.g. the 'turnip' in {a:turnip}) gets send to the object's __format__(self, formatstring) method. So it's very open-ended.

Chalisque
Автор

As someone who's written a function in Python to properly print out a date, I am grateful for your enlightenment. If you want to be enlightened about machine learning, tap my face😅

ChronicoOne
Автор

6:55 could you show us in a separate video how you can make the part set up to handle that in a module similar to the way the datetime module handles it? i know it uses some kind of format function, but that is it.

EvokerKing
Автор

i saw these a couple weeks ago, but i didn't know about the last one

GamingAbroad
Автор

i dont know why i laughed so hard at the start..

bernardcrnkovic
Автор

Can you indicate AM or PM with the time?

richardboreiko
Автор

How did you causally do the start of the video

Heavy_Lvy
Автор

datetime.datetime.datetime lol made my morning! Thank you for that

benfurstenwerth
Автор

Is it possible to make a space " " the thousand separator with f-strings ?

Lanxxe
Автор

Is there a way to swap points and commas in floats, as it is written in Germany, for example?

-awwolf-
Автор

I didn't feel how I lost my 9 mins, I didn't wanna watch it till the end actually 😂

ruzibayevich
Автор

F strings are cool but Zapp's comments are cooler

zapp
Автор

watch video before: proficientin in python
after: heard python

yibing
Автор

Im still disappointed that we can't use a variable in place of that 20 for spacing

Mulakulu