-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython tut 70.py
More file actions
45 lines (32 loc) · 1.21 KB
/
python tut 70.py
File metadata and controls
45 lines (32 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
class Employee:
def __init__(self,fname,lname):
self.fname=fname
self.lname=lname
# self.email=f"{self.fname}.{self.lname}@gamil.com"
def explain(self):
return f" This Employee is {self.fname} {self.lname}"
@property
def email(self):
if self.fname==None or self.lname== None:
return ("Email is not set")
return f"{self.fname}.{self.lname}@gamil.com" #To print hiro after changing fname that was Ansh, Setters are used.
@email.setter # How to set that when an email is typed, the fname and lname change automatically with respect to the email
def email(self,string):
print("Setting now...")
names=string.split("@")[0]
self.fname=names.string.split(".")[0]
self.lname=names.string.split(".")[1]
@email.deleter
def email(self):
self.fname= None
self.lname= None
Ansh=Employee("Ansh",'Dholakia')
# print(Ansh.email)
# print(id()) this function will tell id
o="Viking valhalla"
# print(id("ps4"))
# print(dir(o)) # the attributes asssociate with the variable
# print(dir(Ansh))
import inspect
string=inspect.getmembers(Ansh)
print(*string,sep="\n")