[[Python]]에 새롭게 추가되는 기능들. SeeAlso PythonTip

 * [[http://www.python.or.kr/pykug/_c6_c4_c0_cc_bd_e3_202_2e2_c0_c7_20_bb_f5_b1_e2_b4_c9|2.2]]
 * [[http://www.python.or.kr/pykug/_c6_c4_c0_cc_bd_e3_202_2e3_c0_c7_20_bb_f5_b1_e2_b4_c9|2.3]]
 * [[http://www.python.or.kr/pykug/_c6_c4_c0_cc_bd_e3_202_2e4_c0_c7_20_bb_f5_b1_e2_b4_c9|2.4]]
 * [[Python2.5]]
 * [[Python3.0]]

||<<TableOfContents>>||

== Built in functions ==
 * enumerate() : for문돌릴때 i값까지
 * isinstance(instance, class)
 * object : 최상위객체
 * staticmethod / classmethod : 클래스 정의시 따로 호출함
 * property(getMethod, setMethod) : 클래스정의시 이걸 만들어놓으면, 값을 읽을때 getMethod, 쓸때 setMethod를 자동으로 호출한다.
 * super(C,self) : 자신의 상위클래스 호출
 * bool(), True, False

== List comprehension ==

2.0부터 사용된 리스트 내장기능

{{{#!python
[(x,y) for x in seq1 for y in seq2]
}}}


== Iterator of file ==
파일객체도 라인단위의 반복자 지원
{{{#!python
>>> f = open('readme.txt') 
>>> for line in f: 
        print line, 
}}}

== Iterator / Generator / GeneratorExpression ==

See [[Iterator]], [[Generator]], GeneratorExpression, [[Decorator]]

== 내장자료형 서브클래싱 ==

아래 코드는 의미하는 바가 크다. 문자열처리는 이런 방식으로 하는가 싶고, 내장자료형을 이런방식으로 상속받아서 쓰며, repr을 이용 적절하게 [[Recursion]]을 써먹는것도 눈여겨볼만하다.

{{{#!python
class xmldic(dict): 
    def __repr__(self): 
        res = ['\n<dictionary>'] 
        for k,v in self.items(): 
                res.append('<member>') 
                res.append('<name>%s</name>' % k) 
                res.append('<value>%s</value>' % repr(v)) 
                res.append('</member>') 
        res.append('\n</dictionary>') 
        return '\n'.join(res) 
         
d1 = xmldic({'one':1, 'two':2}) 
d3 = xmldic({'numbers':d1}) 
print d3 
}}}

== source code encoding ==

2.3부터, [[Python]]소스코드의 인코딩 명시. 없으면 디폴트 IsoLatin1

{{{#!python
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
}}}

== Extended slice ==
시퀀스자료형에 모두 적용가능
{{{#!python
>>> L = range(10) 
>>> L[::2] 
[0, 2, 4, 6, 8]
>>> L[::-1]
[9, 8, 7, 6, 5, 4, 3, 2, 1, 0] 
>>> s="abcd"
>>> s[::2]
'ac'
}}}

== 문자열메쏘드 zfill ==
자릿수를 맞춰야하는 문자열들 앞에 0 붙이기
{{{#!python
>>> '45'.zfill(4) 
'0045' 
>>> '12345'.zfill(4) 
'12345' 
>>> 'goofy'.zfill(6) 
'0goofy' 
}}}


== PriorityQueue ==