Skip to content

Commit 340a9c2

Browse files
committed
Setter Implemented
1 parent 3c1846e commit 340a9c2

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed

Employee Getter & Sette.ipynb

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,17 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 1,
5+
"execution_count": 16,
66
"metadata": {},
77
"outputs": [
88
{
9-
"ename": "TypeError",
10-
"evalue": "'str' object is not callable",
11-
"output_type": "error",
12-
"traceback": [
13-
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
14-
"\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)",
15-
"\u001b[1;32m<ipython-input-1-cccbb358e035>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m 14\u001b[0m \u001b[0memp_1\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mEmployee\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"Soumyadip\"\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;34m\"Chowdhury\"\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m900000\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 15\u001b[0m \u001b[0memp_2\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mEmployee\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"Soumyadip\"\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;34m\"Chowdhury\"\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m100000\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 16\u001b[1;33m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0memp_1\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 17\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0memp_2\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 18\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mEmployee\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0memp_1\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
16-
"\u001b[1;31mTypeError\u001b[0m: 'str' object is not callable"
9+
"name": "stdout",
10+
"output_type": "stream",
11+
"text": [
12+
"Soumyadip Chowdhury [email protected] 900000\n",
13+
"Soumyadip Chowdhury [email protected] 100000\n",
14+
"Soumya Dip [email protected] 900000\n",
15+
"Soumyadip Chowdhury [email protected] 100000\n"
1716
]
1817
}
1918
],
@@ -26,17 +25,26 @@
2625
" self.email=f+\".\"+l+\"@python.com\"\n",
2726
" self.pay=p\n",
2827
" \n",
29-
" @property\n",
30-
" def print(self):\n",
28+
" @property # Getter\n",
29+
" def setterEx(self):\n",
3130
" return \"{} {} {} {}\".format(self.first,self.last,self.email,self.pay)\n",
32-
" \n",
31+
" \n",
32+
" @setterEx.setter \n",
33+
" def setterEx(self, name):\n",
34+
" first, last=name.split(' ')\n",
35+
" self.first=first\n",
36+
" self.last=last\n",
3337
" \n",
3438
"emp_1=Employee(\"Soumyadip\",\"Chowdhury\",900000)\n",
3539
"emp_2=Employee(\"Soumyadip\",\"Chowdhury\",100000)\n",
36-
"print(emp_1.print())\n",
37-
"print(emp_2.print())\n",
38-
"print(Employee.print(emp_1))\n",
39-
"print(Employee.print(emp_2))"
40+
"\n",
41+
"print(emp_1.setterEx)\n",
42+
"print(emp_2.setterEx)\n",
43+
"\n",
44+
"emp_1.setterEx=\"Soumya Dip\"\n",
45+
"\n",
46+
"print(emp_1.setterEx)\n",
47+
"print(emp_2.setterEx)"
4048
]
4149
}
4250
],

0 commit comments

Comments
 (0)