Тёмный
No video :(

Python Standard Library: Functools 

Jake Callahan
Подписаться 2 тыс.
Просмотров 1,9 тыс.
50% 1

Опубликовано:

 

29 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 22   
@JakeCallahan
@JakeCallahan 10 месяцев назад
What do you use most from functools? For me, it has to be caching, followed by partials.
@flynnoconnell2260
@flynnoconnell2260 10 месяцев назад
This channel is an absolute gem
@Deemo_codes
@Deemo_codes 10 месяцев назад
Had a use for reduce recently at work. My tester wanted to combine some nested dictionaries, so I wrote a function for him to do it, which took two dictionaries and returned a new dictionary that was the combination of the two. Two days later he said "can we do this with a list of dictionaries" and reduce was the perfect way to do that. I probably wouldn't use this for production code, but for test suite code it ended up being a great solution
@JakeCallahan
@JakeCallahan 10 месяцев назад
Oh nice! If you don't mind sharing, will you put an example in a GitHub gist and link it here?
@Deemo_codes
@Deemo_codes 9 месяцев назад
@JakeCallahan Apologies I've only just seen this. I did another one recently # iterate over a list of directories and read in a parquet file to a spark dataframe # add a filename column to each dataframe duplicates = ( reduce(Dataframe.union, list_of_dataframes).groupby("uniqueid").agg(sf.collect_list("filename").alias("filenames").filter(sf.size(sf.col("filenames")) >1).collect() ) Might need some formatting on that one. Typing on a phone. I'll find the recursive dictionary merge later and post that too
@Deemo_codes
@Deemo_codes 9 месяцев назад
The thing to remember, is that when you call a method from an instance, self is the instance. When you call the same method from a class, you can pass an instance of the class in as self. For example ", ".join(list_of_strings) Or str.join(", ", list_of_strings)
@Deemo_codes
@Deemo_codes 9 месяцев назад
@JakeCallahan def merge_dictionaries(dict1, dict2): all_keys = set(dict1.keys()).union(dict2.keys()) new_dict ={} for key in all_keys(): value = dict1.get(key, dict2.get(key)) If isinstance(value, dict): new_dict[key] = merge_dictionaries(dict1.get(key, {}), dict2.get(key, {})) elif isinstance(value, list): new_dict[key] = [*dict1.get(key, []), *dict2.get(key, [])] return new_dict reduce(merge_dictionaries, list_of_dicts)
@Deemo_codes
@Deemo_codes 9 месяцев назад
It relies on the dictionaries having the same datatype for the same key, and isn't exhaustive. But works for my testers usecase
@halfbakedthoughts4150
@halfbakedthoughts4150 10 месяцев назад
Man i discovered your channel a week back and i am so glad... Great job with these videos🫡
@damus6665
@damus6665 10 месяцев назад
Nice, thanks!
@dipankarbose5933
@dipankarbose5933 10 месяцев назад
20:00 💡 moment you have created factorial using partial reduce ..that's interesting .
@mohamedaymenzebouchi
@mohamedaymenzebouchi 10 месяцев назад
woooooooooooooo
@mohamedaymenzebouchi
@mohamedaymenzebouchi 10 месяцев назад
can you do django plz
@JakeCallahan
@JakeCallahan 10 месяцев назад
I have very little exposure to Django, so would not be a good teacher for a course on that. In the past I've tended to favor Flask, but today would also be inclined to try out FastAPI. Django might be something I revisit in the future, but that won't be anytime soon unfortunately.
@mohamedaymenzebouchi
@mohamedaymenzebouchi 10 месяцев назад
@@JakeCallahan ah🥲, it's ok.
@mohamedaymenzebouchi
@mohamedaymenzebouchi 10 месяцев назад
can you give me a good resource to learn django , like the theory of it plz
@JakeCallahan
@JakeCallahan 10 месяцев назад
Since I haven't personally gone through any available Django courses, I wouldn't want to mislead you with a poor recommendation. I'd hate to waste your time. However, if you do find a Django course you like, please link it here so others can follow your lead!
@mohamedaymenzebouchi
@mohamedaymenzebouchi 10 месяцев назад
@@JakeCallahan I think this channel is good if you want to learn about the "theory" of Django, but i really wanted another resource to learn from. Very Academy:youtube.com/@veryacademy?si=7mF2rSqa3QVkivGK
Далее
Understanding Python: namedtuples
20:06
Просмотров 432
Understanding Python: Logging Basics
17:54
Просмотров 711
New Dyna Skin is OP🥵🔥 | Brawl Stars
00:16
Просмотров 566 тыс.
Scott Irwin - A Hitchhiker’s Guide to functools
33:27
Python Standard Library: Pathlib
23:46
Просмотров 1,1 тыс.
You Can Do Really Cool Things With Functions In Python
19:47
Python Standard Library: Collections
21:43
Просмотров 768
Understanding Python: Descriptors
23:42
Просмотров 6 тыс.
A Deep Dive Into Iterators and Itertools in Python
21:01
Understanding Python: Threading
23:26
Просмотров 1,7 тыс.
PLEASE Use These 5 Python Decorators
20:12
Просмотров 109 тыс.
Understanding Python: Debugging
16:35
Просмотров 432
Functools is one of the MOST USEFUL Python modules
13:37