Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsreader4.netcologne.de!news.netcologne.de!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.010 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'syntax': 0.04; 'error:': 0.07; 'identifier': 0.09; 'methods,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'used.': 0.09; 'wrote': 0.14; 'lambda': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:unicode': 0.16; 'syntaxerror:': 0.16; 'why,': 0.16; 'trying': 0.19; '>>>': 0.22; 'import': 0.22; 'keyboard': 0.24; 'unicode': 0.24; 'math': 0.24; 'question': 0.24; 'header:X -Complaints-To:1': 0.27; 'idea': 0.28; 'character': 0.29; 'gives': 0.31; 'page.': 0.31; 'produces': 0.31; 'lists': 0.32; 'url:python': 0.33; 'but': 0.35; 'method': 0.36; 'url:org': 0.36; 'being': 0.38; 'follows:': 0.38; 'mapping': 0.38; 'to:addr:python- list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'above,': 0.60; 'tell': 0.60; 'url:3': 0.61; 'name': 0.63; 'such': 0.63; 'within': 0.65; 'capable': 0.67; 'invalid': 0.68; 'you:': 0.81; 'characters,': 0.84; 'url:reference': 0.84; 'subject::': 0.85; 'why?': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dave Angel Subject: Re:unicode as valid naming symbols Date: Tue, 25 Mar 2014 15:45:51 -0400 (EDT) Organization: news.gmane.org References: X-Gmane-NNTP-Posting-Host: dpc6744198232.direcpc.com X-Newsreader: PiaoHong Usenet NewsReaders 1.36 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 47 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1395776460 news.xs4all.nl 2872 [2001:888:2000:d::a6]:34369 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:69059 Mark H Harris Wrote in message: > greetings, I would like to create a lamda as follows: > > √ = lambda n: sqrt(n) > > > On my keyboard mapping the "problem" character is alt-v which produces > the radical symbol. When trying to set the symbol as a name within the > name-space gives a syntax error: > > >>> from math import sqrt > >>> > >>> √ = lambda n: sqrt(n) > SyntaxError: invalid character in identifier > >>> > >>> > > however this works: > > >>> > >>> λ = lambda n: sqrt(n) > >>> > >>> λ(2) > 1.4142135623730951 > >>> > > The question is which unicode(s) are capable of being proper name > characters, and which ones are off-limits, and why? See the official docs http://docs.python.org/3/reference/lexical_analysis.html#identifiers There's also a method on str that'll tell you: isidentifier (). To see such methods, use dir ("") As for why, you can get a pretty good idea from the reference above, as it lists 12 unicode categories that can be used. You can also look at pep3131 and at Potsdam ' s site. Both links are on the above page. Letters, marks, connectors, and numbers, but not punctuation. -- DaveA