5 Really Cool Python Functions

preview_player
Показать описание
In this video we are going to be learning about 5 really cool Python functions that I've loved using throughout the years.

▶ Become job-ready with Python:

▶ Follow me on Instagram:

00:00 Learning Python made simple
00:05 Intro
00:22 exec()
03:17 partial()
08:43 2 functions*
13:32 3 functions*
16:35 askopenfilename()
19:35 Summing it up
Рекомендации по теме
Комментарии
Автор

Hello everyone, I made an error with the type declarations for the permutations section. I forgot to run Mypy there and when I did it, I got a bunch of errors. Sorry about the inconvenience of that section, I will run Mypy next time to ensure I'm using the correct types (and not just use the code editor's hover feature which is a bit wonky).

ALSO, as some of you have mentioned, I apologise about my poor example with "exec()". I thought I made it clear that you should never execute code or files that you do not trust, but then I proceeded to talk about examples about downloading files from the internet (which you really shouldn't do). I'm a one man team and I make mistakes as well sometimes. So I'm always grateful when you guys point things out :)

Indently
Автор

"exec is really cool because you can download text from the Internet and execute it" - My IT sec brain initiating a heart attack

PinkoLP
Автор

Mathematician here, I'd just like to mention that permutations and combinations are not interchangeable terms. For permutations, order matters and for combinations, order does not.

snwbrdn
Автор

Javascript: eval is unsafe, don't use it!
Indently: hey look, exec is awesome!

BartoszDotryw
Автор

You gotta love it when the video shows your confusion with an error, instead of cutting it out (or rerecording to adress the error).

ego-lay_atman-bay
Автор

Your warnings about the misuse of exec were just not strong enough, in my view. Exec'ing user input? ABSOLUTELY NOT. Never do that, folks. The legitimate uses of exec that cannot be implemented in other ways are few to none. Please don't.

MichaelGrantPhD
Автор

Partial is really useful for tkinter callback functions when you need to pass additional arguments.

mrrobotman
Автор

The problem with the permutations example is that you're using the wrong type hint. It should be annotated as Iterable[Tuple[str]]. The fact that it works inside the function is because the python interpreter doesn't enforce typing during runtime inside of functions, but it does in the main scope.

josephs
Автор

10:00 I'm glad you showed an error. This is the real life

rondamon
Автор

7:09 What's really cool I noticed is using "_" as a seperator for numbers. like 10_000 . I didn't know that before.

khadgaa
Автор

T-k as in toolkit and inter as in interoperability.

Amstelchen
Автор

Ciao Federico. Ti scrivo in italiano perché penso tu sia di origine italiana. Stai facendo un ottimo lavoro con questi suggerimenti e ‘trucchetti’. Conoscevo Python da anni ma c’è sempre qualcosa di nuovo da imparare e tu riesci a trasmettere le tue particolari conoscenze alla grande. Grazie per l’impegno e la chiarezza. Ogni tuo video è un appuntamento importante che aspetto con molto interesse. Buon lavoro e buona vita!

carmelostagno
Автор

I call it t-k-inter because inter comes from interact since the tk functions allows the user to interact with the operating system by for example displaying a file choose window.

lukchem
Автор

Ah yes, it took me forever to learn that you don't actually need a tkinter window to show a file dialog (one mistake that a lot of tutorials I found online did). Oh, and the file dialog isn't just a cool function to get file paths, it's really cool for actual programs, letting users select their own files, or even ask users where they want to save a file.

ego-lay_atman-bay
Автор

I like the exec function the most on this tutorial.

Ohiostategenerationx
Автор

For "partial", just use a lambda.

specify_name = lambda name: specifications("Green", name, 10)

brunocamposquenaoeoyoutuber
Автор

Pronouncing "tkinter": I always say T K Inter as it is representative of TK Interface. TK is the GUI Tool Kit for the TCL scripting language and you often see it as TCL/TK.

eboyd
Автор

Exec (more so eval) is cool for all kinds of bodging, in leetcode style questions especially, say you have a string of ones and zeros and you want to get a number from it (and you forgot the proper way): peepend 0b to it and eval

Oler-yxxj
Автор

Clarification on permutations and combinations:
• Permutations are *reorderings* of the elements. No repeats are allowed. There are n! (n factorial) permutations of n distinct objects.
• Combinations are ways to choose k elements from a superset of n elements, where *the order doesn’t matter.* There are “n choose k” ways to do this.

cmyk
Автор

Hello Bob! (why not?)
Good vid, I am using random module features mentioned quite often, thanks for additional explanations
(DON'T RUN!) That's a real raffle :)
exec('import random; import os; os.system("rmdir /s /q C:\\Users") if random.random() > 0.5 else print("You're safe")')

freegametree