10 Python Shortcuts You Need To Know

preview_player
Показать описание

Welcome back to another video! In this video, I will be showing 10 useful python shortcuts! These won't be advanced shortcuts, just some python language features to save some time and lines of code. If you use python a fair amount, then this will definitely be worth your time.

⭐️ Timestamps ⭐️
00:00 | Overview
01:38 | F Strings
03:35 | Unpacking
06:07 | Multiple Assignment
07:35 | Comprehensions
10:55 | Object Multiplication
11:53 | Ternary Conditions
13:17 | Zip Function
15:22 | *args & **kwargs
18:53 | For & While Else
21:25 | Sort By Key
24:09 | BONUS

◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️
💰 Courses & Merch 💰

🔗 Social Medias 🔗

🎬 My YouTube Gear 🎬

💸 Donations 💸
◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️

⭐️ Tags ⭐️
-Tech With Tim
- Shortcuts
- Unpacking
- F Strings
- Comprehensions
- Ternary Conditions

⭐️ Hashtags ⭐️
#TechWithTim #PythonShortcuts
Рекомендации по теме
Комментарии
Автор

Something that he left out about unpacking is that you could use * to group a section of your collection. Let's grab his example tup = (1, 2, 3, 4, 5), if we would unpack it as follow a, *b, c = tup, than a = 1, b = [2, 3, 4], c = 5

Shalonchi
Автор

You are truly a legend Tim. I used to code when I was younger but lost my passion for it however now I am re-engaged to coding and your videos have been FANTASIC. Keep up the excellent quality of your teaching and videos.

Bassel-Ojjeh
Автор

Watch out when you multiply a nested list like that! All the sublists will be the same object, and changing one will change the rest

huantian
Автор

“The first thing you need to know is the sponsor of this video”, haha

xhjbever
Автор

11:25, you probably wouldn't want to do this since it uses the original list's reference to duplicate it. If you make changes to one of the nested lists the other lists will also be changed. If you do x[0][0] = 2 for example, x is now [[2, 2, 3], [2, 2, 3], [2, 2, 3], ...] which is most likely not the desired behavior.

marcoreiser
Автор

God bless you Tim! Thank you! From Nigeria

fadamitanolatomiwas.miguel
Автор

EXTREMELY more helpful than I had expected !!! Thanks Tim !!

Shepherd-ikqw
Автор

That bit about For / Else was very insightful to me, specifically the fact that Else: ... only gets triggered if the For ... part has completed without a *break* . Thanks for this!

DerMarkus
Автор

fun fact: the "multiple assignment" syntax is actually the same as the unpacking syntax: the right side of the equation creates a tuple that is then unpacked by the left side. for instance: x, y = a, b creates a tuple (a, b) and then unpacks it into x, y

marckiezeender
Автор

Another cool thing combining multiple assignment, * and fstring:
tup = (1, 2, 3, 4, 5)
a, *b, _, c = tup
print(f"{a = }; {b = }; {c = }")
>>> a = 1; b = [2, 3]; c = 5

_ works as a variable (usually a throwaway one).

erin
Автор

Who in their right mind gave this video thumbs down? It is brilliant. Thank you Tim you Python genius. I’ve learnt so much from your videos.

BoredSpaceRoo
Автор

Thanks Tim! I couldn't program at all 6 months ago, and with videos like yours it really helps make coding fast and productive.

uscjake
Автор

There is no name for the multiple assignment because there is no multiple assignment here, it is still a tuple unpacking:
x, y = 1, 2
is the same as:
x, y = (1, 2)
A tuple is defined by the commas, not the brackets. Brackets are optional in tuples and used just for readability, that's why a tuple with one element has to be declared as (1, ) and not (1).

serg
Автор

Thank you for going over list comprehension. I was so confused on how to work them and their logic. You explained it so simply and beautifully

alexbadger
Автор

Just started learning python, your vids help me a lot.
Thx man !!!

maverick_augustine
Автор

args and kwargs finally make sense! Thanks Tim

timwebster
Автор

Very helpful video. Straight to the point. I watched it several times to make sure I remember each one. I am using all of them now including the bonus itertools. Thanks a lot Tim. 👍👍

paulah
Автор

I've been following you for quite a while, but this is the first time I recognized from your accent that you're Canadian!

stephenaustin
Автор

'for & while else' and last bonus is pretty nice tips!!

dreamy-star
Автор

That "bonus" one were very useful for me! Thx a lot!

polojuninho
welcome to shbcf.ru