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

  Рет қаралды 100,202

CodeWithHarry

CodeWithHarry

Күн бұрын

Пікірлер: 196
@ankushsingh1942
@ankushsingh1942 8 ай бұрын
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 8 ай бұрын
Thanks
@armaanaujla630
@armaanaujla630 6 ай бұрын
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 3 ай бұрын
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
@swatidixit6459
@swatidixit6459 Жыл бұрын
Reached #day 73 and realllyy enjoying each day and gaining knowledge :) Harry sir you are great!!!!!
@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 8 ай бұрын
true
@theankitsagarit
@theankitsagarit Жыл бұрын
Very good and informative content.... This is the most user friendly and learner friendly tutorial channel. Harry bhai 9999 kilo shukriya...
@Realgemigindian777Realgemigind
@Realgemigindian777Realgemigind Ай бұрын
class Nt: def nert(self,n): self.n = n def m(self): print(f"thakiQ yujig disa cod {self.n} PRo !") a = Nt() a.nert(input("antra yuar nema: ")) a.m() Thankiyu aap ne ye cod ko pda ❤
@technomusiccloud9722
@technomusiccloud9722 5 ай бұрын
quickquiz answer🔥🔥🔥 __call__ can be used in a same fasion as help() like to descripe an object and its properties in a readable format
@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 7 ай бұрын
15
@veersinghchauhan6885
@veersinghchauhan6885 8 ай бұрын
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 8 ай бұрын
repr run's if it didn't get any str if it get str then you need use repr() fuction to call it
@RahulVyas-ds4uv
@RahulVyas-ds4uv 16 күн бұрын
Bcz he called this class only once
@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 7 ай бұрын
Yes
@sanjeevthakur6837
@sanjeevthakur6837 Жыл бұрын
call function practical use might be to check the functions in the element
@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
@saradasarawagi6622
@saradasarawagi6622 11 ай бұрын
10:40 to know don't of the major details of class or every object of class or get the information of class
@mehmoodahmed1980
@mehmoodahmed1980 6 ай бұрын
__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
@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.
@mohankilari1747
@mohankilari1747 Жыл бұрын
bro we can actually use the printing of length of name by print(len(e.name))
@narendraparmar1631
@narendraparmar1631 11 ай бұрын
Thanks Harry for your efforts.
@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 Жыл бұрын
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 11 ай бұрын
@@manik6621 bhai i am just curious, why r you crying?
@priyanshupanda2678
@priyanshupanda2678 9 ай бұрын
11:09 the call method can be used to describe the function of the class
@Nikkichaudhary97
@Nikkichaudhary97 9 ай бұрын
Hello kya ham dost ban sakte hai sirf python ikhne k liye?
@parwatsingh677
@parwatsingh677 Жыл бұрын
OP python course 👌👍👍👍🙏
@sasticoaching6738
@sasticoaching6738 7 ай бұрын
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
@UdakshuShorts
@UdakshuShorts Жыл бұрын
best teacher🤩
@avinashyt2942
@avinashyt2942 2 ай бұрын
Best use case. 😅 emp1 = Employee("Harry") emp1() Terminal: Users\Desktop\Code With Harry\100 Days of Python> He is a Naughty Boy😂😂
@ishitagarg2787
@ishitagarg2787 11 ай бұрын
Thanks! You are awesome :)
@siwachjay
@siwachjay Жыл бұрын
BRO, At 3:26 you can also write ----- print(len(e.name))
@HuzaifaKhan-iy5qj
@HuzaifaKhan-iy5qj 4 ай бұрын
Harry bhi, you've unnecessarily complicated this lecture, and I needed to understand it from Jenny's lecture.
@shivastar1148
@shivastar1148 5 ай бұрын
I am glad to watch now
@amankumarverma8426
@amankumarverma8426 Жыл бұрын
Harry bhaiya, if we use print(len(e.name)) then it works fine though
@codegenius9521
@codegenius9521 Жыл бұрын
i think call method can be used by the programmer to tell about the class in simple words
@mdsohanurrahmanhridoy1343
@mdsohanurrahmanhridoy1343 Жыл бұрын
#Completed Day#73/100😍
@rahulatal1816
@rahulatal1816 6 ай бұрын
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__
@meditationmusic6482
@meditationmusic6482 Жыл бұрын
Thanks sir.
@omerqureshi3430
@omerqureshi3430 Жыл бұрын
The spelling of object is wrong on 0:12
@AbdulHadi-qq9hp
@AbdulHadi-qq9hp Жыл бұрын
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 4 ай бұрын
i=i+1 then work
@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
@RasheedKhan-hy6ml
@RasheedKhan-hy6ml Жыл бұрын
harry bhai react native par b 1 playlist banaoo
@PhantomX7157
@PhantomX7157 Жыл бұрын
Love you ❤️❤️
@lakshyachaturvedi2712
@lakshyachaturvedi2712 6 ай бұрын
mere me __str__ use karne par bhi "" ye likh ke aa raha hai jo double quotes me likha hai kya karun?
@shubhamsaini4871
@shubhamsaini4871 Жыл бұрын
Harry bhai aapne 1 baat batai thi ki.. python me sab object hota hai.. please explain how?
@hamrosolution88
@hamrosolution88 Ай бұрын
call method can be used to give final conclusion
@akhtarhameed360
@akhtarhameed360 Жыл бұрын
Harry bhai ik request hai python k bad php k b modern version k course lana
@techbar000
@techbar000 Жыл бұрын
write sir.
@SaigopalakrishnaMaya-j5u
@SaigopalakrishnaMaya-j5u 9 ай бұрын
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
@pankajsinghbisht76
@pankajsinghbisht76 Жыл бұрын
Present Sir #day73
@rajkushwahar
@rajkushwahar Жыл бұрын
ye samjh nhi aaya agar lenth hi nikalni thi to len() ya count() lete phir call kar lete __len__() ka kya faida?
@miri_maau
@miri_maau 4 ай бұрын
at 2.31 we can write print(len(e.name)). It will give len of name. What is the need of __len__(self)method ?
@RishabBharathi
@RishabBharathi Ай бұрын
print('hello world') se start kiya aur aaj hum edhar hain
@RishabBharathi
@RishabBharathi Ай бұрын
@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.
@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?
@shivamchaudhary8592
@shivamchaudhary8592 Жыл бұрын
#Day73 Present Sir
@mark_jugarberg
@mark_jugarberg Жыл бұрын
harry bhaiya i hope i get knowledge like you😍You are alway my inspiration love from bihar🧡
@stain5570
@stain5570 Жыл бұрын
today I think I will finally complete this course I will grind the whole 27 remaining videos in one day
@mansibarewar6295
@mansibarewar6295 8 ай бұрын
really but will you understand info overload???????
@stain5570
@stain5570 8 ай бұрын
​@@mansibarewar6295I already know lots of programming languages so it's not that hard
@ketanverma7839
@ketanverma7839 4 ай бұрын
can this be written print(e.__len__()) ? instead of print(len(e))
@codyandersan
@codyandersan Жыл бұрын
When will you teach us about Walrus Operator??
@dhananjayadk4611
@dhananjayadk4611 Жыл бұрын
Hi Harry bhaiya 💞 from Karnataka
@pradhyudh
@pradhyudh Жыл бұрын
Hai ,i am from Bengaluru
@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
@badalsahoo3902
@badalsahoo3902 Жыл бұрын
Big fan harry bhai😎
@46h1nav
@46h1nav Жыл бұрын
Lal phool neela phool Harry bhaiya beutiful
@dharvikop
@dharvikop Жыл бұрын
Day 73 done
@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
@letscatchup5869
@letscatchup5869 7 ай бұрын
thank you
@AbhishekKumar-jh4cb
@AbhishekKumar-jh4cb Жыл бұрын
sir print (len(e.name)) use kr sakte h naa
@aniketkewat
@aniketkewat Жыл бұрын
Bhai kotlin ka course banao na
@GlitchyGlobe
@GlitchyGlobe 11 ай бұрын
Yeh vide thori difficult thi harry bhai
@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
@lakhyadeepsen
@lakhyadeepsen Жыл бұрын
Day 73 of 100 of python challenge completed. #100DaysofCode #100dayspythonchallenge
@prajwalm.s7976
@prajwalm.s7976 Жыл бұрын
Repeat what you learn till you get hold of it@heavydrivergaming7831
@aryansinha1818
@aryansinha1818 4 ай бұрын
04:30
@abhibagwan6895
@abhibagwan6895 Жыл бұрын
Harry bhai ek video listing kese hoti h us par bnao plzz 🥰❤️
@bhagyabajoria
@bhagyabajoria Жыл бұрын
Sir, I have a question regarding DNS for server: Should I use Cloudflare or Let's Encrypt?
@jp-yu5wz
@jp-yu5wz Жыл бұрын
I'm present 💝
@pradeepgavhane3471
@pradeepgavhane3471 Жыл бұрын
Super bro
@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👍
@NEERAJ-dw9bt
@NEERAJ-dw9bt 8 ай бұрын
Present sir 🤚
@v_i_e_s_s_e
@v_i_e_s_s_e Жыл бұрын
Harry bro 🙌
@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
@manashibarman2036
@manashibarman2036 3 ай бұрын
Sir mera replit free hours khatm ho chuka hai 😢. I use replit in mobile
@anshuvirat45
@anshuvirat45 Жыл бұрын
print(len(e.name)) isse v length nikal sakta h
@volcano_ff
@volcano_ff 4 ай бұрын
Hello sir aa saab kaha work karega 😢😢😢
@Manish-qt1bz
@Manish-qt1bz Жыл бұрын
Present Sir 🔥
@sudhansubalasahoo
@sudhansubalasahoo Жыл бұрын
Present Sir
@hackproud
@hackproud Жыл бұрын
Namaste bhabhi 🙏❣️
@SassyShubhi
@SassyShubhi 9 ай бұрын
mjhe oops ke concept se jada kuch smjh ni aa rha h koi help kro kaise pdhu me
@wonderscraft
@wonderscraft 9 ай бұрын
same bhai bahut hard hai
@SassyShubhi
@SassyShubhi 9 ай бұрын
@@wonderscraft toh kaise krr rhe ho aap help krdo meri bi sath me ho Jayega
@henilrupawala
@henilrupawala Жыл бұрын
Present ✋🏻Sir
@pubpubji1121
@pubpubji1121 10 ай бұрын
Bhai call method smjh me nhi aya 😵😵 baki sab aa gya
@Hivefusion
@Hivefusion Жыл бұрын
Day 73🔥
@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 🤦‍♂
@Radhe_radhe2929
@Radhe_radhe2929 Жыл бұрын
Day 73 🔥
@RohanDasRD
@RohanDasRD Жыл бұрын
Day 73 Done
@gauravsethi17
@gauravsethi17 Жыл бұрын
bro print(len(e.name) is working
@MokshMishra
@MokshMishra Жыл бұрын
that is asnwer of queck qustion
@ayeshaakram3073
@ayeshaakram3073 4 ай бұрын
someone pls mention the __int__() video
@TasinIslam-mc2dk
@TasinIslam-mc2dk Ай бұрын
4.11.2024 day 73 is done.
@asifjavaid6700
@asifjavaid6700 4 ай бұрын
Is lecture ki bilkul smjh nai aiii 😢. Can anyone please explain in simple terms that what are magic methods and why they are used ?
@Zayan7909
@Zayan7909 Ай бұрын
They are just methods defined in a class but they have some speciality like you can see init it is automatically called whenever an object is made . str method prints the short information of the created object
@PhantomX7157
@PhantomX7157 Жыл бұрын
Like krrke bhi jao yyrr
@Relatable2U.
@Relatable2U. 6 ай бұрын
Did something noticed joker mask?
@akbarhusainbhoraniya6949
@akbarhusainbhoraniya6949 Жыл бұрын
kuki error nhi de esliye
@SaiKiranRK-w2h
@SaiKiranRK-w2h Жыл бұрын
# Kya hum ne __repr__ ko call kiya? # !!!!NAHI!!!!! why?
@vatsalshingala3225
@vatsalshingala3225 Жыл бұрын
❤❤❤❤❤❤❤❤
@Uploader12
@Uploader12 Жыл бұрын
😍😍😍😍
@neerajtripathi3523
@neerajtripathi3523 Жыл бұрын
Jaldi jaldi comment kar deta hu like milega 😃😃😛😛
@soriful9417
@soriful9417 Жыл бұрын
🤣🤣🤣
@neerajtripathi3523
@neerajtripathi3523 Жыл бұрын
@@OmDeshmukh00 according to you, what is fresh ? Wahi laya jayy😛😛😂😂
@richit7503
@richit7503 Жыл бұрын
Lol
@irfanmohammad2132
@irfanmohammad2132 Жыл бұрын
Ha ha maine like nahi diya ! Popat
@nileshtayade3546
@nileshtayade3546 Жыл бұрын
Abe chote 🤏🏻 bacche ho kya
Method Overriding in Python | Python Tutorial - Day #74
6:27
CodeWithHarry
Рет қаралды 97 М.
super keyword in Python | Python Tutorial - Day #72
9:08
CodeWithHarry
Рет қаралды 97 М.
Quando eu quero Sushi (sem desperdiçar) 🍣
00:26
Los Wagners
Рет қаралды 14 МЛН
Sigma Kid Mistake #funny #sigma
00:17
CRAZY GREAPA
Рет қаралды 29 МЛН
The evil clown plays a prank on the angel
00:39
超人夫妇
Рет қаралды 51 МЛН
Cheerleader Transformation That Left Everyone Speechless! #shorts
00:27
Fabiosa Best Lifehacks
Рет қаралды 15 МЛН
Python MAGIC METHODS are easy! 🌟
13:36
Bro Code
Рет қаралды 10 М.
How to use AI Effectively - Prompts, Tips & Tricks🔥
14:30
CodeWithHarry
Рет қаралды 71 М.
Python OOP Tutorial 5: Special (Magic/Dunder) Methods
13:50
Corey Schafer
Рет қаралды 869 М.
How To Use Dunder Methods In Python Tutorial (Magic Methods)
6:36
Top Skills to Learn in 2025
9:31
CodeWithHarry
Рет қаралды 186 М.
Magic/Dunder Methods in Python | Python Tutorials #lec106
18:09
Jenny's Lectures CS IT
Рет қаралды 19 М.
5 Mistakes Beginner Web Developers Make (Avoid These)
12:09
CodeWithHarry
Рет қаралды 108 М.
Shallow Copy Vs Deep Copy in Python
12:49
Krish Naik
Рет қаралды 80 М.
__str__ vs __repr__ methods  in Python || Python Tricks
21:11
A Binary Code
Рет қаралды 3,1 М.
dir, __dict__ and help method in Python | Python Tutorial - Day #71
7:23
Quando eu quero Sushi (sem desperdiçar) 🍣
00:26
Los Wagners
Рет қаралды 14 МЛН