Skip to content

Commit f36f2fd

Browse files
committed
By Zhao Kun Peng
1 parent a213c99 commit f36f2fd

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

oop/hasattr.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class Person(object):
2+
def __init__(self,name,age):
3+
self.__name=name
4+
self.age=age
5+
6+
a=Person("lili",18)
7+
getattr(a,"gender",setattr(a,"gender","male"))

0 commit comments

Comments
 (0)