Your SlideShare is downloading. ×
0
파이썬의 Self
파이썬의 Self
파이썬의 Self
파이썬의 Self
파이썬의 Self
파이썬의 Self
파이썬의 Self
파이썬의 Self
파이썬의 Self
파이썬의 Self
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

파이썬의 Self

702

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
702
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. self study이성주페이스북 파이썬 그룹2013-05-18
  • 2. my’self’class LeeSeongjoo:def __init__(self):self.name = u’이성주’self.twitter = ‘@LeeSeongjoo’self.interests = [u‘비디오 얼굴 인식’, u’로마 역사’, u’야구’]def feel_about_python(self):print(u’{} 는 파이썬을 좋아합니다.’.format(self.name))def show_current_interests(self):print(‘n’.join(‘{}: {}’.format(*k) for k in enumerate(self.interests)))>>> sj = LeeSeongjoo()
  • 3. self?class Vector:def __init__(self, x, y):self.x = xself.y = y>>> v = Vector(3, 4)
  • 4. self? (help!)class Vector:def __init__(self, x, y):self.x = xself.y = y>>> v = Vector(3)TypeError: __init__() takes exactly 3arguments (2 given)
  • 5. def length(vector):return math.sqrt(vector.x ** 2 + vector.y **2)class Vector:def __init__(self, x, y):self.x = xself.y = y>>> v = Vector(3, 4)>>> length(v)5.0
  • 6. def length(vector):return math.sqrt(vector.x ** 2 + vector.y **2)class Vector:def __init__(self, x, y):self.x = xself.y = y>>> v = Vector(3, 4)>>> v.length = length>>> v.length(v)5.0
  • 7. class Vector:def __init__(self, x, y):self.x = xself.y = ydef length(self):return math.sqrt(self.x ** 2 + self.y **2)>>> v = Vector(3, 4)>>> v.length()5.0
  • 8. globalself ?class Vector:xx = 3yy = 4def __init__(self, x, y):xx = xyy = ydef length(self):return math.sqrt(xx ** 2 + yy **2)>>> v = Vector(5, 12)>>> v.xx3>>> v.yy4>>> v.length()NameError: global name ‘xx’ is not definedxx  3yy  4length__init__xx  3yy  4self.xself.ylength__init__
  • 9. self? this?class Vector:def __init__(this, x, y):this.x = xthis.y = ydef length(this):return math.sqrt(this.x ** 2 + this.y **2)>>> v = Vector(3, 4)>>> v.length()5.0self는 파이썬 객체. 즉, 키워드가 아니다.
  • 10. >>> sj.say_thank_you()>>> sj.take_questions()>>> sj.exit()

×