Тёмный

Magic/Dunder Methods in Python | Python Tutorial - Day #73 

CodeWithHarry
Подписаться 7 млн
Просмотров 94 тыс.
50% 1

Опубликовано:

 

13 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 188   
@ankushsingh1942
@ankushsingh1942 6 месяцев назад
Quick Quiz Answer class shop: def __init__(self,sales,expenditure): self.sales=sales self.expenditure=expenditure def __call__(self): print(F"The total profit is {self.sales-self.expenditure}") shop1=shop(15000,12000) shop1() Output: The total profit is 3000
@GameWithStuff
@GameWithStuff 6 месяцев назад
Thanks
@armaanaujla630
@armaanaujla630 4 месяца назад
class shop: def __init__(self, expend, sales): self.expend = expend self.sales = sales def __call__(self): if int(self.sales) - int(self.expend) > 0: print(f"The total profit is {int(self.sales) - int(self.expend)}") elif int(self.sales) - int(self.expend) < 0: print(f"The total loss is {int(self.expend) - int(self.sales)}") else: print("No Profit or Loss.") day1 = shop(50000, 70000) day2 = shop(387419, 257692) day3 = shop(50000, 50000) day1() day2() day3() Output: The total profit is 20000 The total loss is 129727 No Profit or Loss.
@mansoorsarookkh
@mansoorsarookkh Месяц назад
thumbs up
@irfanmohammad2132
@irfanmohammad2132 Год назад
I think the practicle use case of def__call__(self ) : method will be to add conclusion to a class or it can used to find total amount at the end of class
@ahsantariq3926
@ahsantariq3926 Год назад
Call method can be used to use a class instance like a function. We can give arguments and executes it however we want
@i_am_dumb1070
@i_am_dumb1070 Год назад
I have never been this consistent with my learning enjoying every minute of this course
@mansibarewar6295
@mansibarewar6295 6 месяцев назад
true
@swatidixit6459
@swatidixit6459 Год назад
Reached #day 73 and realllyy enjoying each day and gaining knowledge :) Harry sir you are great!!!!!
@technomusiccloud9722
@technomusiccloud9722 3 месяца назад
quickquiz answer🔥🔥🔥 __call__ can be used in a same fasion as help() like to descripe an object and its properties in a readable format
@sanjeevthakur6837
@sanjeevthakur6837 Год назад
call function practical use might be to check the functions in the element
@theankitsagarit
@theankitsagarit Год назад
Very good and informative content.... This is the most user friendly and learner friendly tutorial channel. Harry bhai 9999 kilo shukriya...
@probalkar6066
@probalkar6066 Год назад
Harry bhai plz start a machine learning ultimate course too from beginner to advanced really need it 🙏🏼🙏🏼
@sanskarsingh2504
@sanskarsingh2504 Год назад
yes
@rinkukumari4438
@rinkukumari4438 Год назад
Yes
@meenakshi_gupta
@meenakshi_gupta Год назад
Yes
@pradhyudh
@pradhyudh Год назад
Yes
@SonamKumari-xh4jy
@SonamKumari-xh4jy 4 месяца назад
Yes
@LogicOfComputerScience
@LogicOfComputerScience Год назад
Harry bhaiya, I request you... Aap please apne interpreter ka size bada rakha kare. Or console ko small size me rakhe take dekhne me or samajh ne aasani ho... Thank for teach us.
@arpankarmakar16
@arpankarmakar16 Год назад
Quick Quiz: Harry sir in the short time I only found this little application of the __call__ under method: import random import string class Employee: def __init__(self, name) -> None: self.name = name def __call__(self, *args, **kwargs): # this makes the instance callable self.id = "".join( random.choices(self.name + string.ascii_letters + string.digits, k=6) ) print(f"The Employee's ID: {self.id}") e = Employee("Arpan") e() # The dunder/magic method __call__ here, prints the Employee's randomly generated 6 character ID
@mehmoodahmed1980
@mehmoodahmed1980 4 месяца назад
__call__() Method is used to make the instance of class object callable. class Callable: def __call__(self): return "Instance is Callable" instance = Callable() print(callable(instance)) #return True if callable instance() #calling the instance
@mohankilari1747
@mohankilari1747 Год назад
bro we can actually use the printing of length of name by print(len(e.name))
@rahmansherif
@rahmansherif Год назад
QUICK QUIZ ANSWER: class calculator: def __init__(self, base): self.base = base def __call__(self, x): return self.base + x c = calculator(10) print(c(5))
@thekibouminecraft9361
@thekibouminecraft9361 5 месяцев назад
15
@sasticoaching6738
@sasticoaching6738 5 месяцев назад
Prctical use case might be to use the class as an argument to The Function like it may return a list which can be used as a argument in a funcion
@regulusblack8009
@regulusblack8009 Год назад
I think the practical use case of def__call__(self ) : is to add a definition or conclusion of a class which can easily be obtained
@manik6621
@manik6621 9 месяцев назад
bhai i am just curious , yeh pakistan mai koi teachers nhi hote kya online ? sab indian teachers kai comment section mai hi hote hai .!
@aiapro4306
@aiapro4306 9 месяцев назад
@@manik6621 bhai i am just curious, why r you crying?
@rahulatal1816
@rahulatal1816 4 месяца назад
Bro, pls guide for major difference between __new__ and __init__ If __init__ is also a auto-constructor and initializer then why we use __new__ What is the benefit of using __new__ and what problem we face if we Do not use __new__
@saradasarawagi6622
@saradasarawagi6622 8 месяцев назад
10:40 to know don't of the major details of class or every object of class or get the information of class
@priyanshupanda2678
@priyanshupanda2678 6 месяцев назад
11:09 the call method can be used to describe the function of the class
@Nikkichaudhary97
@Nikkichaudhary97 6 месяцев назад
Hello kya ham dost ban sakte hai sirf python ikhne k liye?
@amankumarverma8426
@amankumarverma8426 Год назад
Harry bhaiya, if we use print(len(e.name)) then it works fine though
@AbdulHadi-qq9hp
@AbdulHadi-qq9hp 10 месяцев назад
But sir, we can print the len of name like : # Coding : class Employee: name = "harry" # def __len__(self): # i = 0 # for c in self.name: # i += 1 # return i e = Employee() print(e.name) # print(len(e)) print(len(e.name))
@AhmadKhan-di2cq
@AhmadKhan-di2cq 2 месяца назад
i=i+1 then work
@shubhamsaini4871
@shubhamsaini4871 Год назад
Harry bhai aapne 1 baat batai thi ki.. python me sab object hota hai.. please explain how?
@codegenius9521
@codegenius9521 Год назад
i think call method can be used by the programmer to tell about the class in simple words
@akhtarhameed360
@akhtarhameed360 Год назад
Harry bhai ik request hai python k bad php k b modern version k course lana
@techbar000
@techbar000 Год назад
write sir.
@narendraparmar1631
@narendraparmar1631 9 месяцев назад
Thanks Harry for your efforts.
@miri_maau
@miri_maau 2 месяца назад
at 2.31 we can write print(len(e.name)). It will give len of name. What is the need of __len__(self)method ?
@codyandersan
@codyandersan Год назад
When will you teach us about Walrus Operator??
@siwachjay
@siwachjay Год назад
BRO, At 3:26 you can also write ----- print(len(e.name))
@HuzaifaKhan-iy5qj
@HuzaifaKhan-iy5qj 2 месяца назад
Harry bhi, you've unnecessarily complicated this lecture, and I needed to understand it from Jenny's lecture.
@RasheedKhan-hy6ml
@RasheedKhan-hy6ml Год назад
harry bhai react native par b 1 playlist banaoo
@UdakshuShorts
@UdakshuShorts Год назад
best teacher🤩
@meditationmusic6482
@meditationmusic6482 Год назад
Thanks sir.
@parwatsingh677
@parwatsingh677 Год назад
OP python course 👌👍👍👍🙏
@pankajsinghbisht76
@pankajsinghbisht76 Год назад
Present Sir #day73
@dr.syedinayatullah9125
@dr.syedinayatullah9125 Год назад
Mene aap ka lecture 6 min tak suna lekin muje andaza hogyaa ke muje kuch samaj nahi ane wala. Ab google search kia to muje samaj agaya.
@shivastar1148
@shivastar1148 3 месяца назад
I am glad to watch now
@theroshantune
@theroshantune Год назад
there is only 27 days left to complete this course and i am super excited to see me at day 100 thanks MR. Harry for this amazing course
@nitiksharma3182
@nitiksharma3182 Год назад
bro it's useless just do competitive coding
@mariamhasan3733
@mariamhasan3733 Год назад
@@nitiksharma3182 You know competitive programming requires basics. We can jump on CP right after knowing the basics and applying our knowledge.
@nitiksharma3182
@nitiksharma3182 Год назад
@@mariamhasan3733 for cp you don't require these additional libraries and concept. These concepts sounds good but off no use at current scenario.
@i_am_dumb1070
@i_am_dumb1070 Год назад
@@nitiksharma3182 you are learning for the sake of getting a job but there are people like me who are interested in programming and making their own programs and work on personal projects. Enjoy what you do and take everything as a new experience to learn from Coding is not a pressure its more like a hobby for me.
@nitiksharma3182
@nitiksharma3182 Год назад
@@i_am_dumb1070 sorry bro, I am wrong. you opened my eyes
@bhagyabajoria
@bhagyabajoria Год назад
Sir, I have a question regarding DNS for server: Should I use Cloudflare or Let's Encrypt?
@dharvikop
@dharvikop Год назад
Day 73 done
@mdsohanurrahmanhridoy1343
@mdsohanurrahmanhridoy1343 Год назад
#Completed Day#73/100😍
@ishitagarg2787
@ishitagarg2787 9 месяцев назад
Thanks! You are awesome :)
@ruhbanabdullah7905
@ruhbanabdullah7905 Год назад
Love you ❤️❤️
@Khemchandbhatiya4
@Khemchandbhatiya4 Год назад
I think here we write print so we use it as a function call and we get to know that function is call and it is written in print and we call it easily "call" it not "print" that's my pint other I would to know in my answer
@aniketkewat
@aniketkewat Год назад
Bhai kotlin ka course banao na
@sarv4265
@sarv4265 Год назад
# try to make an object of this LCM class and call it """ from {file_name} import Math a = Math.LCM(6, 14) a() # gives lcm of the two numbers passed in LCM class """ class Math: class LCM: def __init__(self, num1, num2): self.num1 = num1 self.num2 = num2 # checking which number is greater if self.num1 > self.num2: self.smaller = self.num2 self.larger = self.num1 elif self.num1
@letscatchup5869
@letscatchup5869 5 месяцев назад
thank you
@shivamchaudhary8592
@shivamchaudhary8592 Год назад
#Day73 Present Sir
@veersinghchauhan6885
@veersinghchauhan6885 6 месяцев назад
At 7:45 why is it executing only the str method and not the repr method . Even though we have not called either of them while typing print(e). Can anyone help 🙏
@PIYUSHFFYT
@PIYUSHFFYT 5 месяцев назад
repr run's if it didn't get any str if it get str then you need use repr() fuction to call it
@omerqureshi3430
@omerqureshi3430 Год назад
The spelling of object is wrong on 0:12
@GlitchyGlobe
@GlitchyGlobe 8 месяцев назад
Yeh vide thori difficult thi harry bhai
@rajkushwahar
@rajkushwahar 11 месяцев назад
ye samjh nhi aaya agar lenth hi nikalni thi to len() ya count() lete phir call kar lete __len__() ka kya faida?
@abhibagwan6895
@abhibagwan6895 Год назад
Harry bhai ek video listing kese hoti h us par bnao plzz 🥰❤️
@ParshuRam-ey6iz
@ParshuRam-ey6iz Год назад
if i don't keep your photo in my room then i am not worthfulll to watch your priceless vdos 4 free.Thanks
@ketanverma7839
@ketanverma7839 2 месяца назад
can this be written print(e.__len__()) ? instead of print(len(e))
@anshuvirat45
@anshuvirat45 11 месяцев назад
print(len(e.name)) isse v length nikal sakta h
@lakhyadeepsen
@lakhyadeepsen Год назад
Day 73 of 100 of python challenge completed. #100DaysofCode #100dayspythonchallenge
@prajwalm.s7976
@prajwalm.s7976 11 месяцев назад
Repeat what you learn till you get hold of it@heavydrivergaming7831
@sudhansubalasahoo
@sudhansubalasahoo Год назад
Present Sir
@stain5570
@stain5570 Год назад
today I think I will finally complete this course I will grind the whole 27 remaining videos in one day
@mansibarewar6295
@mansibarewar6295 6 месяцев назад
really but will you understand info overload???????
@stain5570
@stain5570 6 месяцев назад
​@@mansibarewar6295I already know lots of programming languages so it's not that hard
@AbhishekKumar-jh4cb
@AbhishekKumar-jh4cb Год назад
sir print (len(e.name)) use kr sakte h naa
@lakshyachaturvedi2712
@lakshyachaturvedi2712 4 месяца назад
mere me __str__ use karne par bhi "" ye likh ke aa raha hai jo double quotes me likha hai kya karun?
@manashibarman2036
@manashibarman2036 27 дней назад
Sir mera replit free hours khatm ho chuka hai 😢. I use replit in mobile
@jp-yu5wz
@jp-yu5wz Год назад
I'm present 💝
@NEERAJ-dw9bt
@NEERAJ-dw9bt 6 месяцев назад
Present sir 🤚
@mark_jugarberg
@mark_jugarberg Год назад
harry bhaiya i hope i get knowledge like you😍You are alway my inspiration love from bihar🧡
@46h1nav
@46h1nav Год назад
Lal phool neela phool Harry bhaiya beutiful
@aryansinha1818
@aryansinha1818 2 месяца назад
04:30
@dhananjayadk4611
@dhananjayadk4611 Год назад
Hi Harry bhaiya 💞 from Karnataka
@pradhyudh
@pradhyudh Год назад
Hai ,i am from Bengaluru
@badalsahoo3902
@badalsahoo3902 Год назад
Big fan harry bhai😎
@sudhansubalasahoo
@sudhansubalasahoo Год назад
QUICK QUIZ ANSWER: We would like to make a class callable to give it some functional ability by calling it using '()'. Like we can create a calculator class and make it callable by giving it some operation inside the parenthesis and call the methods inside the class Well that's what I can think of, if you have any more suggestion, please comment down below
@arpankarmakar16
@arpankarmakar16 Год назад
I wrote a comment on a practical use case I thought of. Please review it
@sudhansubalasahoo
@sudhansubalasahoo Год назад
@@arpankarmakar16 where?
@pradeepgavhane3471
@pradeepgavhane3471 Год назад
Super bro
@MokshMishra
@MokshMishra Год назад
that is asnwer of queck qustion
@uchiha_god_404
@uchiha_god_404 Год назад
#Harrybhai I am in your day 6 I just want to tell u that you have told that this is 100days course but you have taken 1 year to complete but 72% only complete your first video was uploaded in 2022 and it's 2023
@arpankarmakar16
@arpankarmakar16 Год назад
Mf it was uploaded on the last week of Novemeber 🤦‍♂
@SaigopalakrishnaMaya-j5u
@SaigopalakrishnaMaya-j5u 7 месяцев назад
harry bhai in my code i can't get like you if i call the str or repr then also it prints the same thing that what printed in first with out them can you solve it
@gauravsethi17
@gauravsethi17 Год назад
bro print(len(e.name) is working
@Relatable2U.
@Relatable2U. 4 месяца назад
Did something noticed joker mask?
@paraschauhan9978
@paraschauhan9978 Год назад
#day73
@pubpubji1121
@pubpubji1121 8 месяцев назад
Bhai call method smjh me nhi aya 😵😵 baki sab aa gya
@asifjavaid6700
@asifjavaid6700 Месяц назад
Is lecture ki bilkul smjh nai aiii 😢. Can anyone please explain in simple terms that what are magic methods and why they are used ?
@RohanDasRD
@RohanDasRD Год назад
Day 73 Done
@henilrupawala
@henilrupawala Год назад
Present ✋🏻Sir
@SaiKiranRK-w2h
@SaiKiranRK-w2h Год назад
# Kya hum ne __repr__ ko call kiya? # !!!!NAHI!!!!! why?
@v_i_e_s_s_e
@v_i_e_s_s_e Год назад
Harry bro 🙌
@Manish-qt1bz
@Manish-qt1bz Год назад
Present Sir 🔥
@volcano_ff
@volcano_ff 2 месяца назад
Hello sir aa saab kaha work karega 😢😢😢
@shabaazkhan9227
@shabaazkhan9227 Год назад
Which MacBook does he has !? Specs!? Anyone please reply
@Zainab-f6w
@Zainab-f6w Год назад
Present
@aamir1608
@aamir1608 Год назад
Day 73🔥
@ayeshaakram3073
@ayeshaakram3073 2 месяца назад
someone pls mention the __int__() video
@arpankarmakar16
@arpankarmakar16 Год назад
Present sir on #Day73. Kuch bekar k chizo main phas gaya tha isliye itne backlogs bane 😞
@gauravpawar2993
@gauravpawar2993 Год назад
don't be sad it's time to grow up and rock
@vatsalshingala3225
@vatsalshingala3225 Год назад
❤❤❤❤❤❤❤❤
@R_vis
@R_vis Год назад
Harry bhai apne intro mein object ki spelling galat likhi h 😂 hn pta h apko aati h spelling or vo apne nhi likhi h but ek complete video chiyee thi linux k uppr pure din search krne prr bhi linux ka kuch nahi milta or i think coding ka itna high quality content koi nhi bnata so please do something!!! and i don't have much money to those paid courses on other sites ......... HARRY HACKER👍
@Daily_dose_motivation29
@Daily_dose_motivation29 Год назад
Day 73 🔥
@akbarhusainbhoraniya6949
@akbarhusainbhoraniya6949 Год назад
kuki error nhi de esliye
@SassyShubhi
@SassyShubhi 7 месяцев назад
mjhe oops ke concept se jada kuch smjh ni aa rha h koi help kro kaise pdhu me
@wonderscraft
@wonderscraft 7 месяцев назад
same bhai bahut hard hai
@SassyShubhi
@SassyShubhi 7 месяцев назад
@@wonderscraft toh kaise krr rhe ho aap help krdo meri bi sath me ho Jayega
@Uploader12
@Uploader12 Год назад
😍😍😍😍
@thegamingsurprises
@thegamingsurprises 10 месяцев назад
day 73
@hackproud
@hackproud Год назад
Namaste bhabhi 🙏❣️
@ruhbanabdullah7905
@ruhbanabdullah7905 Год назад
Like krrke bhi jao yyrr
@sajidimran414
@sajidimran414 11 месяцев назад
Sir I am Present
@bharathgowda7363
@bharathgowda7363 Год назад
⭐⭐⭐⭐⭐
Далее