PEP 3131: Supporting Non-ASCII Identifiers

Andrea Gavana andrea.gavana at gmail.com
Thu May 17 04:30:23 EDT 2007


Hi All,

> In summary, this PEP proposes to allow non-ASCII letters as
> identifiers in Python.

In primis, I would like to congratulate with Martin to have started
one of the most active threads (flame wars? :- D ) in the python-list
history. By scanning the list from January 2000 to now, this is the
current Python Premier League for Posts (truncated at position 10):

01) merits of Lisp vs Python                             |  832 | Mark
Tarver           | December-2006
02) For review: PEP 308 - If-then-else expression        |  728 |
Guido van Rossum      | February-2003
03) Python syntax in Lisp and Scheme                     |  665 |
mike420 at ziplip.com | October-2003
04) Python from Wise Guy's Viewpoint                     |  495 |
mike420 at ziplip.com | October-2003
05) Microsoft Hatred FAQ                                 |  478 | Xah
Lee               | October-2005
06) Why is Python popular, while Lisp and Scheme aren't? |  430 | Oleg
                 | November-2002
07) Xah Lee's Unixism                                    |  397 |
Pascal Bourguignon    |  August-2004
08) PEP 285: Adding a bool type                          |  361 |
Guido van Rossum      | March-2002
09) Jargons of Info Tech industry                        |  350 | Xah
Lee               | August-2005
10) PEP 3131: Supporting Non-ASCII Identifiers           |  326 |
Martin v. Lowis       | May-2007

(It may come screwed up in the mail, so for those interested I attach
the results in a small text file which contains the first 50
positions).
It has been generated with a simple Python script: you can find it at
the end of the message. It's slow as a turtle (mainly because of the
use of urllib and the sloppiness of my internet connection yesterday
evening), but it works. I obviously will accept all the suggestions
for improvements on the script, as I am only a Python amateurish
programmer.

> So, please provide feedback, e.g. perhaps by answering these
> questions:
> - should non-ASCII identifiers be supported? why?

+1, obviously. As an external observer, it has been extremely
interesting to follow all the discussions that this PEP raised. It has
also been funny, as by reading some of the posts it seemed to me that
my grandmother knows more about unicode with respect to some
conclusions depicted there :-D :-D .
But keep them coming, they are a valuable resource for low-skilled
programmers like me, there is always something new to learn, really.

> - would you use them if it was possible to do so? in what cases?

I will for my personal projects and for our internal applications that
will not go public. As for the usual objection:

> I think your argument about "isolated projects" is flawed. It is not at
> all unusual for code that was never intended to be public, whose authors
> would have sworn that it will never ever be need to read by anyone
> except themselves, to surprisingly go public at some point in the future.

raise NoWayItWillGoPublicError

For Public Domain code, I will surely stick with the standard coding
style we have right now. I thought we were all adults here.
I really imagine what it would happen if we gather all together around
a table for a Python-dining: as soon as PEP 3131 discussion pops in,
we would start throwing food to each other like 5 years-old puckish
boys :-D :-D

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.virgilio.it/infinity77/
-------------- next part --------------
***********************************
* Python Premier League For Posts *
***********************************

POST                                                              SCORE   AUTHOR                                DATE

01) merits of Lisp vs Python                                     |  832 | Mark Tarver                      | December-2006
02) For review: PEP 308 - If-then-else expression                |  728 | Guido van Rossum                 | February-2003
03) Python syntax in Lisp and Scheme                             |  665 | mike420 at ziplip.com            | October-2003
04) Python from Wise Guy's Viewpoint                             |  495 | mike420 at ziplip.com            | October-2003
05) Microsoft Hatred FAQ                                         |  478 | Xah Lee                          | October-2005
06) Why is Python popular, while Lisp and Scheme aren't?         |  430 | Oleg                             | November-2002
07) Xah Lee's Unixism                                            |  397 | Pascal Bourguignon               | August-2004
08) PEP 285: Adding a bool type                                  |  361 | Guido van Rossum                 | March-2002
09) Jargons of Info Tech industry                                |  350 | Xah Lee                          | August-2005
10) PEP 3131: Supporting Non-ASCII Identifiers                   |  326 | "Martin v. Löwis" | May-2007
11) Xah's Edu Corner: What is Expressiveness in a Computer Langu |  306 | Xah Lee                          | March-2006
12) (no subject)                                                 |  296 | richer at eastmail.com           | January-2000
13) PEP0238 lament                                               |  276 | Arthur_Siegel at rsmi.com        | July-2001
14) A critic of Guido's blog on Python's lambda                  |  260 | Xah Lee                          | May-2006
15) Could Python supplant Java?                                  |  255 | netvegetable                     | August-2002
16) age of Python programmers                                    |  250 | Lucas Raab                       | August-2004
17) What's better about Ruby than Python?                        |  246 | Brandon J. Van Every             | August-2003
18) Why don't people like lisp?                                  |  236 | Francis Avila                    | October-2003
19) Language change and code breaks                              |  226 | Terry Reedy                      | July-2001
20) Perl is worse! (was: Python is Wierd!)                       |  214 | Jonathan                         | July-2000
21) Case-sensitivity: why -- or why not? (was Re: Damnation!)    |  212 | Guido van Rossum                 | May-2000
22) [EVALUATION] - E02 - Support for MinGW Open Source Compiler  |  207 | Ilias Lazaridis                  | February-2005
23) anything like C++ references?                                |  201 | Tom Plunket                      | July-2003
24) Why are there no ordered dictionaries?                       |  192 | Christoph Zwerschke              | November-2005
25) Autocoding project proposal.                                 |  190 | Timothy Rue                      | January-2002
26) PEP-308 a "simplicity-first" alternative           |  181 | holger krekel                    | February-2003
27) Class Variable Access and Assignment                         |  170 | Graham                           | November-2005
28) Python's simplicity philosophy (was Re: reduce()--what is it |  168 | Robin Becker                     | November-2003
39) What is a type error?                                        |  168 | David Hopwood                    | June-2006
30) The Industry choice                                          |  163 | Sridhar  R                       | December-2004
31) Still no new license -- but draft text available             |  163 | Guido van Rossum                 | August-2000
32) Wheel-reinvention with Python (was: Ten Essential   Developm |  161 | en.karpachov at ospaz.ru         | July-2005
33) Will python never intend to support private, protected and p |  159 | could ildg                       | September-2005
34) does python have useless destructors?                        |  159 | Michael P. Soulier               | June-2004
35) What is Expressiveness in a Computer Language [off-topic]    |  157 | David Hopwood                    | June-2006
36) Python to use a non open source bug tracker?                 |  155 | Giovanni Bajo                    | October-2006
37) PEP 255: Simple Generators                                   |  154 | Tim Peters                       | June-2001
38) PEP 276 Simple Iterator for ints (fwd)                       |  149 | Lulu of the Lotus-Eaters         | November-2001
39) Of what use is 'lambda'???                                   |  145 | tye4                             | September-2000
40) python coding contest                                        |  145 | Simon Hengel                     | December-2005
41) Could Emacs be rewritten in Python?                          |  145 | Patrick K. O'Brien               | April-2003
42) Python vs. C++ Builder - speed of development                |  143 | pu                               | January-2003
43) Typing system vs. Java                                       |  143 | John Goerzen                     | July-2001
44) Let's Talk About Lambda Functions!                           |  143 | Britt A. Green                   | July-2002
45) proposed language change to int/int==float (was: PEP0238 lam |  142 | Skip Montanaro                   | July-2001
46) Favorite non-python language trick?                          |  141 | Joseph Garvin                    | June-2005
47) Unification of Methods and Functions                         |  141 | David MacQuigg                   | April-2004
48) Python's 8-bit cleanness deprecated?                         |  138 | Roman Suzi                       | February-2003
49) Status of PEP's?                                             |  138 | Gonçalo Rodrigues           | February-2002

Scanning Process Took: 01h:57m:34s


Bye Bye From FlameWars :-D
-------------- next part --------------
# -*- coding: utf-8 -*-

import urllib
import heapq
import datetime
import time
from operator import itemgetter

defaultUrl = '''http://mail.python.org/pipermail/python-list/%(postTime)s/thread.html'''
MAXTHREADLEN = 60 

def fractSec(s):

   min, s = divmod(s, 60)
   h, min = divmod(min, 60)
   return h, min, s


def ReadUrl(url):
    
    pythonList = urllib.urlopen(url)
    pythonThreads = pythonList.read()
    pythonList.close()
    return pythonThreads.split("\n")


def AssignThreads(singleThread, flameDict, postDate):
    
    for indx, thread in enumerate(singleThread):

        # We check only the messages embedded in the <LI> tag    
        if "<LI>" not in thread:
            continue

        threadTitle = thread.split(">")[-1:]
        threadTitle = "".join(threadTitle)
        threadAuthor = singleThread[indx+2].replace("<I>", "")
        
        # Check if the flameDict has this key
        keys = flameDict.keys()
        if threadTitle in keys:
            flameDict[threadTitle][0] += 1
        else:
            # Try to find a renamed thread that still has 
            # the original title in it
            renamedThread = False
            for key in keys:
                if threadTitle in key:
                    flameDict[key][0] += 1
                    renamedThread = True 
                    break

            if not renamedThread:
                # That's really a new thread
                flameDict[threadTitle] = [1, threadAuthor, postDate]


def FlameWars():

    localtime = time.localtime()
    currentMonth, currentYear = localtime.tm_mon, localtime.tm_year
    
    months = xrange(1, 13)
    years = xrange(2000, currentYear+1)
    numScanned = 0
    flameDict = {} 
    
    # Loop over the selected years    
    for year in years:
        # Loop over the selected months
        for month in months:
            # Don't go further than the current time
            if month > currentMonth and year == currentYear: 
                return flameDict

            # Format the date for the web page
            theDate = datetime.date(year, month, 1)
            dateDict = dict(postTime=theDate.strftime("%Y-%B"))

            print "Examining Posts At", theDate.strftime("%B-%Y")

            # Build the url as a dog meal for urllib
            url = defaultUrl % dateDict
            singleThread = ReadUrl(url)
            # Here we go... scan for an esisting thread in Python newsgroup 
            AssignThreads(singleThread, flameDict, theDate.strftime("%B-%Y"))

            numScanned += 1
            
            if numScanned%4 == 0:
                # eliminate the less common posts older than 4 months
                # Here I am taking only the 50 most common one 
                bestPost = heapq.nlargest(50, flameDict.iteritems(), itemgetter(1))
                numScanned = 0
                
    return flameDict


def PrettyPrint(flameDict):

    print "\n\n***********************************"
    print "* Python Premier League For Posts *"
    print "***********************************\n"

    maxThreadLen = maxUserLen = 0
    
    for key, values in flameDict:
        # Find the longest thread name 
        maxThreadLen = min(MAXTHREADLEN, max(maxThreadLen, len(key)))
        # Find the longest user name 
        maxUserLen = max(maxUserLen, len(values[1]))

    print "POST" + " "*maxThreadLen + "  SCORE" + " "*3 + "AUTHOR" + \
          " "*maxUserLen + "DATE\n"
    
    for indx, items in enumerate(flameDict): 
        # Format a pretty print string
        # I know is a mess!
        lenThread = len(items[0][0:MAXTHREADLEN])
        lenUser = len(items[1][1])
        concat = "%02d"%(indx+1) + ") " + items[0][0:MAXTHREADLEN] + \
                 " "*(maxThreadLen-lenThread) + \
                 " | " + "%4s"%items[1][0] + " | " + items[1][1] + \
                 " "*(maxUserLen-lenUser) + " | " + items[1][2] 

        print concat        

    
if __name__ == "__main__":

    startTime = time.time()
    print "\n\nFlameWars Started... It May Take A While :-D\n"    

    flameDict = FlameWars()
    flameDict = heapq.nlargest(50, flameDict.iteritems(), itemgetter(1))

    PrettyPrint(flameDict)
    endTime = time.time()

    h, m, s = fractSec(endTime-startTime)
    print "\nScanning Process Took: %02dh:%02dm:%02ds\n"%(h, m, s)

    print "\nBye Bye From FlameWars :-D\n"



More information about the Python-list mailing list