2013-10-20 1 views
11

알파벳 문자, 숫자 및 밑줄을 제외하고 파이썬 함수 이름에 허용되는 다른 문자가 있습니까? 그렇다면 무엇입니까?파이썬 함수 이름에 허용되는 문자

+0

하면 구글 : http://www.pasteur.fr/formation/infobio/python/ch02s03.html 파이썬에서 사용할 수있는 문자 [의 – BartoszKP

+0

가능한 중복 클래스 이름] (http://stackoverflow.com/questions/10120295/valid-characters-in-a-python-class-name) – Ben

+0

[변수 및 함수 이름에 대한 Python의 명명 규칙이란 무엇입니까?] http://stackoverflow.com/questions/159720/what-is-the-naming-convention-in-python-for-variable-and-function-names) – tecmec

답변

14

Python 2.x에는 없습니다. the docs에서 :

identifier ::= (letter|"_") (letter | digit | "_")* 
letter  ::= lowercase | uppercase 
lowercase ::= "a"..."z" 
uppercase ::= "A"..."Z" 
digit  ::= "0"..."9" 

In Python 3 it's expanded :

identifier ::= xid_start xid_continue* 
id_start  ::= <all characters in general categories Lu, Ll, Lt, Lm, Lo, Nl, 
        the underscore, and characters with the Other_ID_Start property> 
id_continue ::= <all characters in id_start, plus characters in the categories 
        Mn, Mc, Nd, Pc and others with the Other_ID_Continue property> 
xid_start ::= <all characters in id_start whose NFKC normalization 
        is in "id_start xid_continue*"> 
xid_continue ::= <all characters in id_continue whose NFKC normalization 
        is in "id_continue*"> 

The Unicode category codes mentioned above stand for: 

Lu - uppercase letters 
Ll - lowercase letters 
Lt - titlecase letters 
Lm - modifier letters 
Lo - other letters 
Nl - letter numbers 
Mn - nonspacing marks 
Mc - spacing combining marks 
Nd - decimal numbers 
Pc - connector punctuations 
Other_ID_Start - explicit list of characters in PropList.txt 
       to support backwards compatibility 
Other_ID_Continue - likewise 
+3

Python 3.x 문서의 모든 버전을 가리키면 대답은 yes입니다. 예 : http://docs.python.org/3.2/reference/lexical_analysis.html#identifiers –

+0

@JonClements D' oh! 편집 됨. –

관련 문제