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