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.
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.
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.
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❤
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.
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.
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)
"It's cool because there is Bob" 😂
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.
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.
In that case we can use *re.sub*
use " red " in that case. space before and after. with " blue " .
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.
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
Yeah, 're' is amazing
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❤
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.
Another alternative is subclassing dict and defining the __missing__ method. It has the bonus of providing the key to compute the default dynamically
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))
Very interesting, didn't think of that
#13 "Bob, who's obviously named Jeff" - gets me every time... 🤣🤣🤣
Lot of great tips in this vid. Probably will watch again later, lol.
Some tips really helped me. Thanks!
Great video. My interest was peaked while watching.
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.
Yeah another indently vid! :D
Your content is very useful
This is Gold!
What happens if one gets from the dictionary, "Bob" instead of getting "name?"
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)
Included with the python std lib there is a module called 're' that allows you to find and replace using regex
splendid...keep up good work.
Thank you for this very useful video. Can I ask you what theme you use in Pycharm?
pretty sure he uses the default
He made python more simpler
I use these tricks everyday
11:15 for those in a country that swaps the decimal and comma in numbers:
f'{big_number:_}'.replace('.', ',').replace('_', '.')
damn actually useful
Great video
Very nice 👍🙂
I love python
what i prefer in string multifaction is using an f string f'{'A'*20}H!'
13:21
... it looks quite confusing.
Haskell: Good luck!
Nice
33 sec ago was wild
🎉
print(*_) gives a space-delimited row of names, not a list object.
😮
Ha ha ha.
i can't believe you typed "odd" with zero instead of capital 'o'... this is bothering me...
what kind of syntax is this a: str="text" ?
normally I just write a="text"
never seen before in python.
He wrote the numeral zero in the word "Odd" instead of the capital letter O. 😮
If one wants to comvine two dicrionaries a and b, then why not simply a + b?
Python is beautiful, but counter: Counter = Counter() is just not ZEN.
I know, right? Get yer dang Java outta my Python
I know right? Get yer dang Java outta my Python!
what is the difference __str__ and __repr__
Poor Bob, being byte by like 20 small pythons... sheez...
Praise Bob
Why you have adverbs if you have sponsored video?
What do you mean? “An adverb is a word or an expression that generally modifies a verb, adjective, another adverb”.
@@Martin-deltayou’re kidding right? It’s too deadpan.
@@DrDeuteron lol no. I was genuinely confused. I just copied the Wikipedia entry for adverb. 🤷♀️
aHHHhhaa (!)
Lame... seen these "tips" 1_000_000 times before....
i like the pun here
really undurated!