20 Everyday Tips & Tricks in Python

  Рет қаралды 24,059

Indently

Indently

Күн бұрын

Пікірлер: 60
@mateuszzebala
@mateuszzebala 3 ай бұрын
"It's cool because there is Bob" 😂
@יהבלזר
@יהבלזר 3 ай бұрын
really undurated!
@cefarix
@cefarix 3 ай бұрын
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.
@Владислав-м3е9г
@Владислав-м3е9г 3 ай бұрын
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 3 ай бұрын
Yeah, 're' is amazing
@DrDeuteron
@DrDeuteron 3 ай бұрын
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.
@GOPINATH-jx1su
@GOPINATH-jx1su 2 ай бұрын
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❤
@lesheq85
@lesheq85 3 ай бұрын
i can't believe you typed "odd" with zero instead of capital 'o'... this is bothering me...
@rubenvanderark4960
@rubenvanderark4960 3 ай бұрын
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 3 ай бұрын
In that case we can use *re.sub*
@shittuto
@shittuto 20 күн бұрын
use " red " in that case. space before and after. with " blue " .
@richardbennett4365
@richardbennett4365 3 ай бұрын
What happens if one gets from the dictionary, "Bob" instead of getting "name?"
@richardbennett4365
@richardbennett4365 3 ай бұрын
print(*_) gives a space-delimited row of names, not a list object. 😮 Ha ha ha.
@mudi2000a
@mudi2000a 3 ай бұрын
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 3 ай бұрын
Another alternative is subclassing dict and defining the __missing__ method. It has the bonus of providing the key to compute the default dynamically
@jeffreyphipps1507
@jeffreyphipps1507 3 ай бұрын
#13 "Bob, who's obviously named Jeff" - gets me every time... 🤣🤣🤣
@laytonjr6601
@laytonjr6601 3 ай бұрын
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 3 ай бұрын
Included with the python std lib there is a module called 're' that allows you to find and replace using regex
@rokaskarabevicius
@rokaskarabevicius 3 ай бұрын
Python is beautiful, but counter: Counter = Counter() is just not ZEN.
@chrisdieguez1950
@chrisdieguez1950 2 ай бұрын
I know, right? Get yer dang Java outta my Python
@chrisdieguez1950
@chrisdieguez1950 2 ай бұрын
I know right? Get yer dang Java outta my Python!
@enksek
@enksek 2 ай бұрын
what kind of syntax is this a: str="text" ? normally I just write a="text" never seen before in python.
@Heavy_Lvy
@Heavy_Lvy Ай бұрын
what i prefer in string multifaction is using an f string f'{'A'*20}H!'
@cdm1972
@cdm1972 Ай бұрын
Lot of great tips in this vid. Probably will watch again later, lol.
@richardbennett4365
@richardbennett4365 3 ай бұрын
He wrote the numeral zero in the word "Odd" instead of the capital letter O. 😮
@richardbennett4365
@richardbennett4365 3 ай бұрын
If one wants to comvine two dicrionaries a and b, then why not simply a + b?
@theorange6460
@theorange6460 3 ай бұрын
I use these tricks everyday
@syrupthesaiyanturtle
@syrupthesaiyanturtle 2 ай бұрын
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 2 ай бұрын
Very interesting, didn't think of that
@wujublazedman6984
@wujublazedman6984 3 ай бұрын
33 sec ago was wild
@rishiraj2548
@rishiraj2548 3 ай бұрын
🎉
@ChXXL
@ChXXL Ай бұрын
Some tips really helped me. Thanks!
@anon_y_mousse
@anon_y_mousse 3 ай бұрын
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.
@Muso-c8j
@Muso-c8j 2 ай бұрын
what is the difference __str__ and __repr__
@luketurner314
@luketurner314 3 ай бұрын
11:15 for those in a country that swaps the decimal and comma in numbers: f'{big_number:_}'.replace('.', ',').replace('_', '.')
@Chaminox
@Chaminox Ай бұрын
damn actually useful
@369Gamer
@369Gamer 3 ай бұрын
Your content is very useful
@alexcaffri9091
@alexcaffri9091 7 күн бұрын
aHHHhhaa (!)
@vslabs-za
@vslabs-za 3 ай бұрын
Poor Bob, being byte by like 20 small pythons... sheez...
@吳政霖-b9t
@吳政霖-b9t 3 ай бұрын
13:21 ... it looks quite confusing. Haskell: Good luck!
@JG-gy3tt
@JG-gy3tt 3 ай бұрын
Great video. My interest was peaked while watching.
@christopheanfry2425
@christopheanfry2425 3 ай бұрын
Thank you for this very useful video. Can I ask you what theme you use in Pycharm?
@novamc7945
@novamc7945 2 ай бұрын
pretty sure he uses the default
@loverboykimi
@loverboykimi 3 ай бұрын
This is Gold!
@troshujin
@troshujin 3 ай бұрын
Yeah another indently vid! :D
@arb6t9
@arb6t9 3 ай бұрын
He made python more simpler
@AfzalKhan-dp9zh
@AfzalKhan-dp9zh 3 ай бұрын
splendid...keep up good work.
@BobChess
@BobChess 3 ай бұрын
I love python
@Anonymous-6598
@Anonymous-6598 3 ай бұрын
Great video
@kumaranb8702
@kumaranb8702 3 ай бұрын
Very nice 👍🙂
@kamurashev
@kamurashev 3 ай бұрын
Nice
@Pawlo370
@Pawlo370 3 ай бұрын
Why you have adverbs if you have sponsored video?
@Martin-delta
@Martin-delta 3 ай бұрын
What do you mean? “An adverb is a word or an expression that generally modifies a verb, adjective, another adverb”.
@DrDeuteron
@DrDeuteron 3 ай бұрын
@@Martin-deltayou’re kidding right? It’s too deadpan.
@Martin-delta
@Martin-delta 3 ай бұрын
@@DrDeuteron lol no. I was genuinely confused. I just copied the Wikipedia entry for adverb. 🤷‍♀️
@neuromorphing9933
@neuromorphing9933 3 ай бұрын
Lame... seen these "tips" 1_000_000 times before....
@sridharhisaria
@sridharhisaria 3 ай бұрын
i like the pun here
5 Great Python Project Ideas
8:53
Indently
Рет қаралды 14 М.
5 Useful Dunder Methods In Python
16:10
Indently
Рет қаралды 60 М.
Остановили аттракцион из-за дочки!
00:42
Victoria Portfolio
Рет қаралды 3,8 МЛН
БЕЛКА СЬЕЛА КОТЕНКА?#cat
00:13
Лайки Like
Рет қаралды 2,5 МЛН
GIANT Gummy Worm Pt.6 #shorts
00:46
Mr DegrEE
Рет қаралды 99 МЛН
The Joker wanted to stand at the front, but unexpectedly was beaten up by Officer Rabbit
00:12
25 nooby Python habits you need to ditch
9:12
mCoding
Рет қаралды 1,8 МЛН
Learn Python OOP in under 20 Minutes
18:32
Indently
Рет қаралды 39 М.
How To Use List Comprehension In Python
6:41
Taylor's Software
Рет қаралды 8 М.
10 Nooby Mistakes Devs Often Make In Python
24:31
Indently
Рет қаралды 62 М.
My 10 “Clean” Code Principles (Start These Now)
15:12
Conner Ardman
Рет қаралды 231 М.
5 Really Cool Python Functions
19:58
Indently
Рет қаралды 62 М.
5 Cool Python One-Liners
12:23
Indently
Рет қаралды 34 М.
10 Important Python Concepts In 20 Minutes
18:49
Indently
Рет қаралды 141 М.
Enums Explained In Under 12 Minutes In Python
12:03
Indently
Рет қаралды 22 М.
5 Useful Python Decorators (ft. Carberra)
14:34
Indently
Рет қаралды 101 М.
Остановили аттракцион из-за дочки!
00:42
Victoria Portfolio
Рет қаралды 3,8 МЛН