20 Everyday Tips & Tricks in Python

  Рет қаралды 27,010

Indently

Indently

Күн бұрын

Пікірлер: 62
@mateuszzebala
@mateuszzebala 5 ай бұрын
"It's cool because there is Bob" 😂
@cefarix
@cefarix 5 ай бұрын
Just wanted to point out that defining __ call __ on a class makes _instances_ of that class callable not the class itself. All classes are callable anyways since that's how you create new instances.
@DrDeuteron
@DrDeuteron 5 ай бұрын
No 15: overloading repr() is a good idea. You can also use "type(self).__name__" or self.__class___.__name__ instead of the explicit "Person" in the f-string.
@rubenvanderark4960
@rubenvanderark4960 5 ай бұрын
21:44 If you replace just " red" with " blue", the string " reduced" would still turn into " blueduced". Also, the string "red" would be unchanged because it doesn't start with a space.
@mk00088
@mk00088 5 ай бұрын
In that case we can use *re.sub*
@shittuto
@shittuto 2 ай бұрын
use " red " in that case. space before and after. with " blue " .
@Владислав-м3е9г
@Владислав-м3е9г 5 ай бұрын
21:40 - I would use regex here, as instead of spaces there might be some other separations + upper case problem would be solved as well
@aaronvegoda1907
@aaronvegoda1907 4 ай бұрын
Yeah, 're' is amazing
@mudi2000a
@mudi2000a 5 ай бұрын
Regarding default values for dictionaries, you should also have a look at the collections.defaultdict class which I find very useful. There you can specify a general default value that you get if the key doesn't exist. This is very useful e.g. if you want to count something.
@DavideCanton
@DavideCanton 4 ай бұрын
Another alternative is subclassing dict and defining the __missing__ method. It has the bonus of providing the key to compute the default dynamically
@syrupthesaiyanturtle
@syrupthesaiyanturtle 4 ай бұрын
23:50 you can also use a tuple as a key to achieve multilayer sorting such as min(names, key = lambda name: (name.lower().count('a'), name))
@olfmombach260
@olfmombach260 4 ай бұрын
Very interesting, didn't think of that
@ChXXL
@ChXXL 3 ай бұрын
Some tips really helped me. Thanks!
@jeffreyphipps1507
@jeffreyphipps1507 5 ай бұрын
#13 "Bob, who's obviously named Jeff" - gets me every time... 🤣🤣🤣
@cdm1972
@cdm1972 3 ай бұрын
Lot of great tips in this vid. Probably will watch again later, lol.
@JG-gy3tt
@JG-gy3tt 4 ай бұрын
Great video. My interest was peaked while watching.
@anon_y_mousse
@anon_y_mousse 4 ай бұрын
As a corollary to multiplying strings and arrays, I overloaded / so that I could divide them as well. Take for instance "ababab"/"ab" would yield 3, and "bababa"/3 would yield "ba". You could probably make a video on showing an implementation of that. It would likely be better than mine.
@troshujin
@troshujin 5 ай бұрын
Yeah another indently vid! :D
@369Gamer
@369Gamer 5 ай бұрын
Your content is very useful
@laytonjr6601
@laytonjr6601 5 ай бұрын
Using replace(' thing', ' other') doesn't work for words that start with thing (the same way replace('thing ', 'other ') doesn't work for words that end with thing (and if the character behind it is not a space, for exemple a period or a comma, it won't work either)
@aaronvegoda1907
@aaronvegoda1907 4 ай бұрын
Included with the python std lib there is a module called 're' that allows you to find and replace using regex
@GOPINATH-jx1su
@GOPINATH-jx1su 4 ай бұрын
2:59 Tip no 1:😅 No need to use number%2==0 there instead use number%2 only, because number%2 always gives you either 0 or 1,if 0 => False, if 1 => True😅❤ Note: change Even as Odd and Odd as Even😅😂 Good Teaching❤
@loverboykimi
@loverboykimi 5 ай бұрын
This is Gold!
@arb6t9
@arb6t9 5 ай бұрын
He made python more simpler
@AfzalKhan-dp9zh
@AfzalKhan-dp9zh 5 ай бұрын
splendid...keep up good work.
@luketurner314
@luketurner314 5 ай бұрын
11:15 for those in a country that swaps the decimal and comma in numbers: f'{big_number:_}'.replace('.', ',').replace('_', '.')
@richardbennett4365
@richardbennett4365 5 ай бұрын
What happens if one gets from the dictionary, "Bob" instead of getting "name?"
@Chaminox
@Chaminox 3 ай бұрын
damn actually useful
@theorange6460
@theorange6460 5 ай бұрын
I use these tricks everyday
@Anonymous-6598
@Anonymous-6598 5 ай бұрын
Great video
@kumaranb8702
@kumaranb8702 5 ай бұрын
Very nice 👍🙂
@BobChess
@BobChess 5 ай бұрын
I love python
@christopheanfry2425
@christopheanfry2425 5 ай бұрын
Thank you for this very useful video. Can I ask you what theme you use in Pycharm?
@novamc7945
@novamc7945 4 ай бұрын
pretty sure he uses the default
@Jason-b9t
@Jason-b9t 5 ай бұрын
13:21 ... it looks quite confusing. Haskell: Good luck!
@kamurashev
@kamurashev 5 ай бұрын
Nice
@Heavy_Lvy
@Heavy_Lvy 3 ай бұрын
what i prefer in string multifaction is using an f string f'{'A'*20}H!'
@richardbennett4365
@richardbennett4365 5 ай бұрын
If one wants to comvine two dicrionaries a and b, then why not simply a + b?
@richardbennett4365
@richardbennett4365 5 ай бұрын
print(*_) gives a space-delimited row of names, not a list object. 😮 Ha ha ha.
@richardbennett4365
@richardbennett4365 5 ай бұрын
He wrote the numeral zero in the word "Odd" instead of the capital letter O. 😮
@lesheq85
@lesheq85 5 ай бұрын
i can't believe you typed "odd" with zero instead of capital 'o'... this is bothering me...
@Muso-c8j
@Muso-c8j 4 ай бұрын
what is the difference __str__ and __repr__
@enksek
@enksek 4 ай бұрын
what kind of syntax is this a: str="text" ? normally I just write a="text" never seen before in python.
@p_j_keenan
@p_j_keenan 2 күн бұрын
It's an optional way to specify the type of the variable. Search for python type hinting and you'll find loads on the subject.
@wujublazedman6984
@wujublazedman6984 5 ай бұрын
33 sec ago was wild
@rishiraj2548
@rishiraj2548 5 ай бұрын
🎉
@rokaskarabevicius
@rokaskarabevicius 4 ай бұрын
Python is beautiful, but counter: Counter = Counter() is just not ZEN.
@chrisdieguez1950
@chrisdieguez1950 4 ай бұрын
I know, right? Get yer dang Java outta my Python
@chrisdieguez1950
@chrisdieguez1950 4 ай бұрын
I know right? Get yer dang Java outta my Python!
@vslabs-za
@vslabs-za 5 ай бұрын
Poor Bob, being byte by like 20 small pythons... sheez...
@kspen72
@kspen72 Ай бұрын
Praise Bob
@Pawlo370
@Pawlo370 5 ай бұрын
Why you have adverbs if you have sponsored video?
@Martin-delta
@Martin-delta 5 ай бұрын
What do you mean? “An adverb is a word or an expression that generally modifies a verb, adjective, another adverb”.
@DrDeuteron
@DrDeuteron 5 ай бұрын
@@Martin-deltayou’re kidding right? It’s too deadpan.
@Martin-delta
@Martin-delta 5 ай бұрын
@@DrDeuteron lol no. I was genuinely confused. I just copied the Wikipedia entry for adverb. 🤷‍♀️
@alexcaffri9091
@alexcaffri9091 2 ай бұрын
aHHHhhaa (!)
@neuromorphing9933
@neuromorphing9933 5 ай бұрын
Lame... seen these "tips" 1_000_000 times before....
@sridharhisaria
@sridharhisaria 5 ай бұрын
i like the pun here
@יהבלזר
@יהבלזר 5 ай бұрын
really undurated!
5 Great Python Project Ideas
8:53
Indently
Рет қаралды 17 М.
Please Master These 10 Python Functions…
22:17
Tech With Tim
Рет қаралды 217 М.
Из какого города смотришь? 😃
00:34
МЯТНАЯ ФАНТА
Рет қаралды 2,6 МЛН
1, 2, 3, 4, 5, 6, 7, 8, 9 🙈⚽️
00:46
Celine Dept
Рет қаралды 115 МЛН
ТЫ В ДЕТСТВЕ КОГДА ВЫПАЛ ЗУБ😂#shorts
00:59
BATEK_OFFICIAL
Рет қаралды 4,6 МЛН
5 Good Python Practices
23:05
Indently
Рет қаралды 20 М.
5 Useful Dunder Methods In Python
16:10
Indently
Рет қаралды 63 М.
25 nooby Python habits you need to ditch
9:12
mCoding
Рет қаралды 1,8 МЛН
5 Tips To Write Better Python Functions
15:59
Indently
Рет қаралды 111 М.
How To Use List Comprehension In Python
6:41
Taylor's Software
Рет қаралды 11 М.
Avoid These BAD Practices in Python OOP
24:42
ArjanCodes
Рет қаралды 74 М.
10 Nooby Mistakes Devs Often Make In Python
24:31
Indently
Рет қаралды 67 М.
10 Crazy Python Operators That I Rarely Use
11:37
Indently
Рет қаралды 43 М.
How To Write Better Functions In Python
14:17
Indently
Рет қаралды 49 М.