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.
@DrDeuteron5 ай бұрын
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.
@rubenvanderark49605 ай бұрын
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.
@mk000885 ай бұрын
In that case we can use *re.sub*
@shittuto2 ай бұрын
use " red " in that case. space before and after. with " blue " .
@Владислав-м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
@aaronvegoda19074 ай бұрын
Yeah, 're' is amazing
@mudi2000a5 ай бұрын
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.
@DavideCanton4 ай бұрын
Another alternative is subclassing dict and defining the __missing__ method. It has the bonus of providing the key to compute the default dynamically
@syrupthesaiyanturtle4 ай бұрын
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))
@olfmombach2604 ай бұрын
Very interesting, didn't think of that
@ChXXL3 ай бұрын
Some tips really helped me. Thanks!
@jeffreyphipps15075 ай бұрын
#13 "Bob, who's obviously named Jeff" - gets me every time... 🤣🤣🤣
@cdm19723 ай бұрын
Lot of great tips in this vid. Probably will watch again later, lol.
@JG-gy3tt4 ай бұрын
Great video. My interest was peaked while watching.
@anon_y_mousse4 ай бұрын
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.
@troshujin5 ай бұрын
Yeah another indently vid! :D
@369Gamer5 ай бұрын
Your content is very useful
@laytonjr66015 ай бұрын
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)
@aaronvegoda19074 ай бұрын
Included with the python std lib there is a module called 're' that allows you to find and replace using regex
@GOPINATH-jx1su4 ай бұрын
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❤
@loverboykimi5 ай бұрын
This is Gold!
@arb6t95 ай бұрын
He made python more simpler
@AfzalKhan-dp9zh5 ай бұрын
splendid...keep up good work.
@luketurner3145 ай бұрын
11:15 for those in a country that swaps the decimal and comma in numbers: f'{big_number:_}'.replace('.', ',').replace('_', '.')
@richardbennett43655 ай бұрын
What happens if one gets from the dictionary, "Bob" instead of getting "name?"
@Chaminox3 ай бұрын
damn actually useful
@theorange64605 ай бұрын
I use these tricks everyday
@Anonymous-65985 ай бұрын
Great video
@kumaranb87025 ай бұрын
Very nice 👍🙂
@BobChess5 ай бұрын
I love python
@christopheanfry24255 ай бұрын
Thank you for this very useful video. Can I ask you what theme you use in Pycharm?
@novamc79454 ай бұрын
pretty sure he uses the default
@Jason-b9t5 ай бұрын
13:21 ... it looks quite confusing. Haskell: Good luck!
@kamurashev5 ай бұрын
Nice
@Heavy_Lvy3 ай бұрын
what i prefer in string multifaction is using an f string f'{'A'*20}H!'
@richardbennett43655 ай бұрын
If one wants to comvine two dicrionaries a and b, then why not simply a + b?
@richardbennett43655 ай бұрын
print(*_) gives a space-delimited row of names, not a list object. 😮 Ha ha ha.
@richardbennett43655 ай бұрын
He wrote the numeral zero in the word "Odd" instead of the capital letter O. 😮
@lesheq855 ай бұрын
i can't believe you typed "odd" with zero instead of capital 'o'... this is bothering me...
@Muso-c8j4 ай бұрын
what is the difference __str__ and __repr__
@enksek4 ай бұрын
what kind of syntax is this a: str="text" ? normally I just write a="text" never seen before in python.
@p_j_keenan2 күн бұрын
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.
@wujublazedman69845 ай бұрын
33 sec ago was wild
@rishiraj25485 ай бұрын
🎉
@rokaskarabevicius4 ай бұрын
Python is beautiful, but counter: Counter = Counter() is just not ZEN.
@chrisdieguez19504 ай бұрын
I know, right? Get yer dang Java outta my Python
@chrisdieguez19504 ай бұрын
I know right? Get yer dang Java outta my Python!
@vslabs-za5 ай бұрын
Poor Bob, being byte by like 20 small pythons... sheez...
@kspen72Ай бұрын
Praise Bob
@Pawlo3705 ай бұрын
Why you have adverbs if you have sponsored video?
@Martin-delta5 ай бұрын
What do you mean? “An adverb is a word or an expression that generally modifies a verb, adjective, another adverb”.
@DrDeuteron5 ай бұрын
@@Martin-deltayou’re kidding right? It’s too deadpan.
@Martin-delta5 ай бұрын
@@DrDeuteron lol no. I was genuinely confused. I just copied the Wikipedia entry for adverb. 🤷♀️
@alexcaffri90912 ай бұрын
aHHHhhaa (!)
@neuromorphing99335 ай бұрын
Lame... seen these "tips" 1_000_000 times before....