2013-10-20 9 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

संभावित डुप्लिकेट [चरम और फ़ंक्शन नामों के लिए पायथन में नामकरण सम्मेलन क्या है?] (http://stackoverflow.com/questions/159720/what-is-the-naming-convention-in-python-for-variable-and-function-names) – tecmec

उत्तर

14

पायथन 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

पायथन 3.x दस्तावेज़ों के किसी भी संस्करण को इंगित करें, और उत्तर हाँ है :) उदाहरण: http://docs.python.org/3.2/reference/lexical_analysis.html#identifiers –

+0

@ जोनक्लेमेंट्स डी ओह! संपादित। –

संबंधित मुद्दे