No One Has EVER Seen THIS Before In Python

preview_player
Показать описание
No one has ever seen this before in Python. #Code #Python #Programming
Рекомендации по теме
Комментарии
Автор

Quickest way to get fired as a jr software engineer

MattXChrist
Автор

Btw you could make it more pythonic

def IIFE(func):
return func()

@IIFE
def func() -> str:
...

hadawardgz
Автор

This hurts my brain. Imma needa rewatch this a few times.

deemon
Автор

Could be useful for running main functions or a config loader

jmanh
Автор

i can confirm this can be used in some goofy malware 💀

yousef_darsh
Автор

JS IIFEs are pretty easy to wrap your head around if they're small.

But even though the example was very small, the python version is hard to read... I would like to know the use cases it provides for.

kinositajona
Автор

saw it in a JS article written on 2010 Immediately-Invoked Function Expression (IIFE)

back in the day they were hella trendy

ko-Daegu
Автор

You should replace func() with a function which updates your LinkedIn and submits your CV all over the internet and then use the decorator.

anibaldk
Автор

Please, don't use this in Python because it breaks the Zen of Python.

GaucheraTopVidz
Автор

We used to call the lambda you created, "apply".

futureundead
Автор

THIS IS NOT RECOMMENDEND BECAUSE THE MAIN MANTRA OF PYTHON IS READABILITY

GaucheraTopVidz
Автор

It's not a bug. It's a feature.

shinej
Автор

I hope I never see this type of code again.

Calaharie
Автор

I see it could be used for a function which is loading data from database into Tkinter Treeview widget. While opening a window with a Treeview, it would use the decorator. And after that, if there was a need to reload whole treeview, I could use direct call of the function.
What do you think?

teo
Автор

Doesn't the __init__ function run automatically in a class when defining an instance? Is that an example of an IIFE?

skerJG
Автор

I can see this being useful if you're building a framework to load dependencies/configs. I don't write in python, but that would be my best guess.

cabbage-dev
Автор

I can guarantee that you’ve probably never thought about the crushing weight of your own sins. Pay attention to it, you can almost feel the pull of gravity growing exponentially with every passing second.

Mywifeleftme
Автор

believe me it has lots of use cases, the way i have seen these kinds of tricks is to combine them with a dictionary that act as a map of a case to run a function base on that case, today it is done by match case, but in the old days mapping a case to a function was done like that

xzex
Автор

I see a possible usage scenario where you want to perform some initialization only once and said initialization involved calling a bunch of functions or is otherwise complex

alexismandelias
Автор

"It's just executing an anonymous function wtf it's named that long?!" - any Javascript coders.

christopherjaya