Koi bhi chiz sikhne ke phle hme us chiz me interest aana chahiye. Usk bad vo kuch bhi sikh skta hai.. Pr sach kahu to harry bhai aapke vidio dekhne ke bad interest hi interest aa raha hai. Boring se coading ab interesting lgne lgi hai. Dil se kah raha hu bhai..
import inspect class inspector: def __init__(self, obj): self.obj = obj def object_inspector(self): for item in inspect.classify_class_attrs(inspector): print(item) the_object = inspector("CodeWithHarry") the_object.object_inspector() -- iske through kisi bhi string ka instropection kar sakte hai...yeh saare attrb. ke names display karega
@@helpinghand524 Taki pure class me kabhi bhi hume kisi object ka "obj" use karna pade to hum "self.obj" likh ke use kar sakte hai. Varna sirf "obj" likh ke use nahi kar sakte.
import inspect class Inspect: def insp(self): a = inspect.isclass(Inspect) print("Checking its class or not...") if a == True: print("It is a class") if a == False: print("Not a class") a = Inspect() print(a.insp())
import inspect class Cars: def __init__(self,Cname): self.name=Cname def explain(self): return f"The Car name is: {self.name}" @property def inspect(self): a=inspect.isclass(Cars) if a==True: print("It's a class") else: print("It's not a class") C1=Cars("Tata") C1.inspect
import inspect class Egadgets: def __init__(self, aname, aprice): self.name = aname self.price = aprice def explain(self): return f"Name of the product is {self.name} and it's price is {self.price}" class Earphones(Egadgets): def __init__(self, aname, aprice, model): super().__init__(self, aname) self.model = model def explain(self): return f"Name of the product is {self.name}, it's price is {self.price} and model is {self.model}" Mobile1 = Egadgets("Huawei",7000) # Ear1 = Earphones("Boat",700) a = inspect.getmembers(Mobile1, inspect.ismethod) print("Methods used are = ", a) b = inspect.getmembers(Mobile1, inspect.isclass) print("Classes are = ", b) c = inspect.getmembers(Mobile1, inspect.isbuiltin) print("Builtins are = ", c)
class A: Job_time="9 to 5" def __init__(self,name,working_days): self.name=name self.working_days=working_days def introducing(self): return (f"The name of the employee is:{self.name} he/she has to work for " f"{self.working_days} no. of days")
@classmethod def greet(cls,time): if time.upper()=="MORNING": return f"Good {time}" elif time.upper()=="AFTERNOON": return f"Good {time}" else: return f"Good {time}" tanish=A("Tanish",100) print(tanish.greet("Morning")) import inspect as i print(i.ismethod(tanish)) print(i.getcomments(tanish)) print(i.getsource(A)) for key,data in i.getmembers(tanish): if key.startswith("__"): print(data)
Task of inspect: def Inspect_somethingect(something, ch): import inspect if (ch==1): # check whether the arguement is a class or not if (inspect.isclass(something)): return f"'{something}' is a class."
# check whether the arguement is a module or not elif (inspect.ismodule(something)): return f"'{something}' is a module." # check whether the arguement is a function or not elif (inspect.isfunction(something)): return f"'{something} is a function."
# check whether the arguement is a method of a class or not elif (inspect.ismethod(something)): return f"'{something}' is a method."
if (ch==2): # returns the class hierarchy return f"Hierarchy of {something} object is {inspect.getmro(something)}"
if (ch==3): # returns all the methods, attributes with values of the class. return inspect.getmembers(something)
if (ch==4): # returns all the parameters passed to a given function return inspect.signature(something)
if (ch==5): # returns the source code of given class, module, method, function return inspect.getsource(something)
if (ch==6): # returns the module name of the method or function passed in it. return inspect.getmodule(something)
if (ch==7): # returns the docstring of the method. return inspect.getdoc(something)
import inspect class Asif: def __init__(self,name,fame): self.name=name self.fame=fame def pri(self): return f" name is {self.name}, fame is {self.fame}" def pri2(self): print("these items are members") for item in inspect.getmembers(asif): print(item) asif=Asif('asif','programmer') print(asif.pri2())
# Practice::: from abc import ABC , abstractmethod class FatherOfA(ABC): @abstractmethod def SumOfConstructorValues(self): return None # Return value can be modified..... @abstractmethod def Multiplication(self): return None # Return value can be modified.... class A(FatherOfA): def __init__(self,x,y): self.x = x self.y = y def Returner(self): return "The value of [x] is %f and [y] is %f"%(self.x,self.y) # Abstract Class Method.... def SumOfConstructorValues(self): return f"The sum of {self.x} and {self.y} = {self.x + self.y}" def Multiplication(self): return f"The multiplication of {self.x} and {self.y} = {self.x * self.y}" def __mul__(self, other): '''These type of methods are also called Dunder Method''' a = self.x * other.y b = self.x * other.y Multiply = A(a,b) return Multiply a = A(8,4) b = A(6,8) ab = a*b # print(f"Multiplication of {a.x} and {b.x} = ",ab.x) def RequiredFunc(): print("Hello World") # Self Exploring................................................................................................................................................................................................ import inspect # Importing the module.. print("Inspect Module::") print("===================================================================================================================================================================") print("Statement 1:") IsClass = inspect.isclass(A) print("Exameple :",end = " ") print(f"The method isclass() returns true when the given argument in this function is a class Argument >> [{A}:[Function Returns >>{IsClass}]") print("==================================================================================================================================================================") print("Statement 2:") IsFunction = inspect.isfunction(RequiredFunc) print("Example :",end = " ") print(f"The method isfunction() returns true when the given argument in the function is type of function Argument >> {RequiredFunc} Returns >> {IsFunction}") print("===================================================================================================================================================================") print("Statement 3:") GetMembers = inspect.getmembers(A) print("Example :",end = " ") print(f"The method getmembers() returns all the attributes including [Functions , variables , objects] of the class which is passed as the argument in this functions... Argument >> {A} Returns >> {list(GetMembers)}") print("====================================================================================================================================================================") print("Statement 4:") import pygame as py# Importing a module for test.... IsModule = inspect.ismodule(py)# Pass the module name.... print("Example :",end = " ") print(f"The method ismodule() returns true when the when the given argument in this function is a module in python's library otherwise it will return false.... Argument >> {py} returns >> {IsModule}") print("=====================================================================================================================================================================") print("Documentation End.....")
#challenge accepted import inspect class Employee: def __init__(self,fname,lname): self.fname=fname self.lname=lname Shivansh=Employee("Shivansh","Varshney") def insp(emp): inspect.isclass(emp) while True: print(dir(emp)) break emp=input('write your word here : ') insp(emp) print('you can use this function')
Challenge accepted import inspect class Inspect: def insp(self): a = inspect.isclass(Inspect) return a b = inspect.ismodule(inspect) return b a = Inspect() print(a.insp()) b = Inspect() print(b.insp())
import inspect class Human: def __init__(self, fname, lname): self.fname = fname self.lname = lname def explain(self): return f"this is {self.fname} {self.lname}" @property def inspection(self): a = inspect.isclass(human) print ("Identify that it's a class or not: ") if a == True: print("It's a class.") else: print("It's not a class !!") human = Human("Haris","Khan") human.inspection
One of the best python course on TH-cam
Yes
one of the nahi
only
best python course on TH-cam
Best python tutorial in you tube
Koi bhi chiz sikhne ke phle hme us chiz me interest aana chahiye. Usk bad vo kuch bhi sikh skta hai..
Pr sach kahu to harry bhai aapke vidio dekhne ke bad interest hi interest aa raha hai. Boring se coading ab interesting lgne lgi hai.
Dil se kah raha hu bhai..
sahi hai
Yes hnn
#1
import inspect
class A:
pass
print(inspect.isclass(A))
#2
import inspect
import math
print(inspect.getmembers(math))
This course is proven very fruitful and helpful for us thank you so much HARRY SIR to creat such a fruitful videos for us.....
i will be a good programmer, i am a good programmer, love you harry bhai.
i know much kuch samajh nhi aata h, but aapka video bahut acha lagta h.
import inspect
class inspector:
def __init__(self, obj):
self.obj = obj
def object_inspector(self):
for item in inspect.classify_class_attrs(inspector):
print(item)
the_object = inspector("CodeWithHarry")
the_object.object_inspector()
-- iske through kisi bhi string ka instropection kar sakte hai...yeh saare attrb. ke names display karega
Dekhne me lagta hai kya hi kar diya but jab pata chala ki sirf for loop me inspect ka ek method run kiya hai tab chain ki saans mili.
ye self.obj = obj kyu kara he?
@@helpinghand524 Taki pure class me kabhi bhi hume kisi object ka "obj" use karna pade to hum "self.obj" likh ke use kar sakte hai. Varna sirf "obj" likh ke use nahi kar sakte.
9 people who have disliked this video have probably spend thier money in white hat JR LOL
'White hat JR' is just a introduction to programming not PYTHON or JAVA
you are right. not only white hat jr but also other course providers. lol
Please add you comment 9 to 12
import inspect
class inspector:
def __init__(self, obj):
self.obj = obj
def object_inspector(self):
for item in inspect.classify_class_attrs(inspector):
print(item)
the_object = inspector("CodeWithHarry")
the_object.object_inspector()
Bro,plz cover database connectivity (oracle and SQL server). Waiting for it
I am excepting this challenge !!👍
God bless you!
Harry bhi ka task bohot help karta he samajne me 👍
import inspect
class Inspect:
def insp(self):
a = inspect.isclass(Inspect)
print("Checking its class or not...")
if a == True:
print("It is a class")
if a == False:
print("Not a class")
a = Inspect()
print(a.insp())
import inspect
class Cars:
def __init__(self,Cname):
self.name=Cname
def explain(self):
return f"The Car name is: {self.name}"
@property
def inspect(self):
a=inspect.isclass(Cars)
if a==True:
print("It's a class")
else:
print("It's not a class")
C1=Cars("Tata")
C1.inspect
harry bhai thank you so much from pakistan.
import inspect
class Employee:
def __init__(self,fname,lname):
self.fname=fname
self.lname=lname
Shivansh=Employee("Shivansh","Varshney")
def insp(emp):
inspect.isclass(emp)
while True:
print(dir(emp))
break
emp=input()
insp(emp)
ye lijiye sir aapka answer
while loop faltu me laga diya. use nikal code sahi chalega
Object Shivansh name ka bnaya h fir emp input kyu le rho ho .
Kehna kya chahte ho bhai 😂😂😂
import inspect
class Phones:
def __init__(self, a):
self.name = "iphone"
self.ram = 4
self.battery = 4000
def printdetails(self):
return f"Name is {self.name}, Ram is {self.ram} and Battery is {self.battery}."
jk = Phones()
print(inspect.getmembers(jk))
arguments toh de do
import inspect
class Egadgets:
def __init__(self, aname, aprice):
self.name = aname
self.price = aprice
def explain(self):
return f"Name of the product is {self.name} and it's price is {self.price}"
class Earphones(Egadgets):
def __init__(self, aname, aprice, model):
super().__init__(self, aname)
self.model = model
def explain(self):
return f"Name of the product is {self.name}, it's price is {self.price} and model is {self.model}"
Mobile1 = Egadgets("Huawei",7000)
# Ear1 = Earphones("Boat",700)
a = inspect.getmembers(Mobile1, inspect.ismethod)
print("Methods used are = ", a)
b = inspect.getmembers(Mobile1, inspect.isclass)
print("Classes are = ", b)
c = inspect.getmembers(Mobile1, inspect.isbuiltin)
print("Builtins are = ", c)
skillf the most mysterious thing in my coding journey. bhai iske bare me kabhi batana
Timestamp 5:36 i accepted this challenge sir .
I am excepting this challenge...
Big Help Thank You
i am accepct this chanllage
Sir kotlin pr banaoge video ap baad m ya ni
I am excepting this challenge!
import inspect
class Employee:
no_of_leaves = 8
def __init__(self,aname,asalary, arole):
self.name= aname
self.salary= asalary
self.role= arole
def __str__(self):
return str(inspect.getmembers(self))
Suhashi = Employee("Suhashi",10000, "Developer")
print(Suhashi)
class A:
Job_time="9 to 5"
def __init__(self,name,working_days):
self.name=name
self.working_days=working_days
def introducing(self):
return (f"The name of the employee is:{self.name} he/she has to work for "
f"{self.working_days} no. of days")
@classmethod
def greet(cls,time):
if time.upper()=="MORNING":
return f"Good {time}"
elif time.upper()=="AFTERNOON":
return f"Good {time}"
else:
return f"Good {time}"
tanish=A("Tanish",100)
print(tanish.greet("Morning"))
import inspect as i
print(i.ismethod(tanish))
print(i.getcomments(tanish))
print(i.getsource(A))
for key,data in i.getmembers(tanish):
if key.startswith("__"):
print(data)
OP same here..
nice
Did not understand what you have dd but looks good
acepting this challange
Thank You Harry Bhai..!!
Task of inspect:
def Inspect_somethingect(something, ch):
import inspect
if (ch==1):
# check whether the arguement is a class or not
if (inspect.isclass(something)):
return f"'{something}' is a class."
# check whether the arguement is a module or not
elif (inspect.ismodule(something)):
return f"'{something}' is a module."
# check whether the arguement is a function or not
elif (inspect.isfunction(something)):
return f"'{something} is a function."
# check whether the arguement is a method of a class or not
elif (inspect.ismethod(something)):
return f"'{something}' is a method."
if (ch==2):
# returns the class hierarchy
return f"Hierarchy of {something} object is
{inspect.getmro(something)}"
if (ch==3):
# returns all the methods, attributes with values of the class.
return inspect.getmembers(something)
if (ch==4):
# returns all the parameters passed to a given function
return inspect.signature(something)
if (ch==5):
# returns the source code of given class, module, method, function
return inspect.getsource(something)
if (ch==6):
# returns the module name of the method or function passed in it.
return inspect.getmodule(something)
if (ch==7):
# returns the docstring of the method.
return inspect.getdoc(something)
Nice!!!
sir Django kab se start krege deeply wala or machine learning k practical plz implement kr ke dikhaiye ml ka Al ka
Is id same as address in C or Cpp
Bhai Ya OOp Bohot Sahi Chheze Hai!.. Pehle Samajh Nahi aa Raha Thga.. Ab Maza aaa raha hai!
import inspect
class Asif:
def __init__(self,name,fame):
self.name=name
self.fame=fame
def pri(self):
return f" name is {self.name}, fame is {self.fame}"
def pri2(self):
print("these items are members")
for item in inspect.getmembers(asif):
print(item)
asif=Asif('asif','programmer')
print(asif.pri2())
class A:
ram = "name"
shyam = "middlename"
mehta = "surname"
def __init__(self, fname, lname):
self.fname = fname
self.lname = lname
object1 = A("Raju", "Kumar")
object2 = A("Maju", "Kumar")
import inspect
def func1(cls):
if inspect.isclass(cls) == True:
attributes = [attr for attr in dir(cls)
if not attr.startswith('__')]
return attributes
print(func1(A))
i'm acpecting this challange
Challenge accepted-
import inspect
def sum(a,b):
return a+b
print(inspect.isfunction(sum))
I accept the challenge🤝❤
How different Object INtrospection is from __repr__ & __str__ method?
Best tutorial
sir please creat a playlist only html base
Dict function se bhi m ye kr skta hu
Like object.__dict__
Toh dir ko kyu usme kre isme hum
Thank you 😊
Accepted
# Practice:::
from abc import ABC , abstractmethod
class FatherOfA(ABC):
@abstractmethod
def SumOfConstructorValues(self):
return None # Return value can be modified.....
@abstractmethod
def Multiplication(self):
return None # Return value can be modified....
class A(FatherOfA):
def __init__(self,x,y):
self.x = x
self.y = y
def Returner(self):
return "The value of [x] is %f and [y] is %f"%(self.x,self.y)
# Abstract Class Method....
def SumOfConstructorValues(self):
return f"The sum of {self.x} and {self.y} = {self.x + self.y}"
def Multiplication(self):
return f"The multiplication of {self.x} and {self.y} = {self.x * self.y}"
def __mul__(self, other):
'''These type of methods are also called Dunder Method'''
a = self.x * other.y
b = self.x * other.y
Multiply = A(a,b)
return Multiply
a = A(8,4)
b = A(6,8)
ab = a*b
# print(f"Multiplication of {a.x} and {b.x} = ",ab.x)
def RequiredFunc():
print("Hello World")
# Self Exploring................................................................................................................................................................................................
import inspect # Importing the module..
print("Inspect Module::")
print("===================================================================================================================================================================")
print("Statement 1:")
IsClass = inspect.isclass(A)
print("Exameple :",end = " ")
print(f"The method isclass() returns true when the given argument in this function is a class
Argument >> [{A}:[Function Returns >>{IsClass}]")
print("==================================================================================================================================================================")
print("Statement 2:")
IsFunction = inspect.isfunction(RequiredFunc)
print("Example :",end = " ")
print(f"The method isfunction() returns true when the given argument in the function is type of function
Argument >> {RequiredFunc} Returns >> {IsFunction}")
print("===================================================================================================================================================================")
print("Statement 3:")
GetMembers = inspect.getmembers(A)
print("Example :",end = " ")
print(f"The method getmembers() returns all the attributes including [Functions , variables , objects] of the class which is passed as the argument in this functions...
Argument >> {A} Returns >> {list(GetMembers)}")
print("====================================================================================================================================================================")
print("Statement 4:")
import pygame as py# Importing a module for test....
IsModule = inspect.ismodule(py)# Pass the module name....
print("Example :",end = " ")
print(f"The method ismodule() returns true when the when the given argument in this function is a module in python's library otherwise it will return false....
Argument >> {py} returns >> {IsModule}")
print("=====================================================================================================================================================================")
print("Documentation End.....")
Challenge Accepted bhai
Now i will defently do it
mujhe bhi ek dil deto n bhai plz
and I will submit in few minutes sir
😊
I have accepted this challenge
Bhai baar baar run karne par ID change kyu ho rahi hain?
I am accepting the challenge!
Answer for your question with this function of inspect module you can figure out the source of the object.
I accept this challenge Harry Bhaiya
👍👍👍👍💯💯💯
challenge accepted bhaiya !!!!!!!
I'm accepting the challenge...sir
bhai kivy sikhao yrr ap gui development ke liye plz
Accepting this challenge
Gui development pe banaoge aab aap
Bahut hi jaldi aapko Python GUI pe videos dekhne ko milenge!
@@CodeWithHarry Aa gaye videos bhai
Love it
Sir please Kotlin ka course banaye
I am excepting this chalenge
I accept the challenge harry bhai
🤣
#challenge accepted
import inspect
class Employee:
def __init__(self,fname,lname):
self.fname=fname
self.lname=lname
Shivansh=Employee("Shivansh","Varshney")
def insp(emp):
inspect.isclass(emp)
while True:
print(dir(emp))
break
emp=input('write your word here :
')
insp(emp)
print('you can use this function')
I am accepting the challenge 😌
sir please also make a tutorials on hacking
Challenge accepted
import inspect
class Inspect:
def insp(self):
a = inspect.isclass(Inspect)
return a
b = inspect.ismodule(inspect)
return b
a = Inspect()
print(a.insp())
b = Inspect()
print(b.insp())
I am excepting this challenge
I am trying this challange😜
I am accepting the challenge 😁
challenge accepted
easy he pr time yaar kal se paper bhi start ho rhe hein
I accepted the challenge
Hey Harry!! I am accepting this challenge.
#day70
Oka
I am eccepting this challange.
🔥🔥🔥
Dear sir, I am accepting this challenge.
I accepted your challenge
I am excepting this challenge (≧▽≦)
I am expecting this chalange
I accept the challenge
i accept the challenge
Challenge exepted
Answer kaha hai
i am accepting this challanmge
I accept this challange
I'm accepting this challenge !!!
Harris Bhai I am accepting your challenge!!!
accepted
Challenge excepted
I am Accepting your Challange
I accept this challenge
import inspect
print(inspect.ismodule(SkillF))
print(inspect.isclass(SkillF))
print((inspect.isbuiltin(SkillF)))
👍👍👍👍
CHALLANGE ACCEPTED!!!!!!
challenge accepted !!
Accepting challenge
import inspect
class Human:
def __init__(self, fname, lname):
self.fname = fname
self.lname = lname
def explain(self):
return f"this is {self.fname} {self.lname}"
@property
def inspection(self):
a = inspect.isclass(human)
print ("Identify that it's a class or not: ")
if a == True:
print("It's a class.")
else:
print("It's not a class !!")
human = Human("Haris","Khan")
human.inspection
bro thoda acche se samjha do
pls explain with more examples
this is just a request
-king of coding
I'm accepting this chalega
i have accepted this channel ajao bheskipooochhhh
Sir please help Karo
Meri python file exe me transfer nahi ho Raha he
Msg me
Accept the challenge
I'm Accepting this Challenge