Language change and code breaks

Bengt Richter bokr at accessone.com
Sat Jul 21 15:32:40 EDT 2001


On Fri, 20 Jul 2001 14:39:51 GMT, Guido van Rossum <guido at python.org> wrote:

>Mikael Olofsson <mikael at isy.liu.se> writes:
>
>> On 19-Jul-2001 Guido van Rossum wrote:
>>  >  Bruce Sass <bsass at freenet.edmonton.ab.ca> writes:
>>  >  
>>  > > The short of it is... ya got less symbols to work with, therefore it
>>  > > is less <something>... why is that good for programmers?
>>  >  
>>  >  You flunked math, right?  The number of available identifiers is still
>>  >  infinite...
>> 
>> That comment was not necessary. What Bruce must mean is that the average
>> length of an identifier will be larger with case insensitiveness than 
>> with case sensitiveness. I am sure you understood that.
>
>I apologize for the comment.  But I don't find the argument (that
>case-sensitivity reduces the expressivity or the number of available
>good identifiers) convincing at all.  Given that in current code,
>case-insensitive name clashes are very rare, I don't believe for a
>second that the average identifier length will go up.  If you use this
>a lot (message = Message() etc.) your code is less readable than it
>should be.  It also makes it harder to discuss code in person or over
>the phone -- spoken language is not case-preserving, as anyone who has
>tried to give someone a URL over the phone knows. :-)
>

I don't know if the following uses of the same symbol with case variations
qualify as "case-insensitive name clashes" the way you meant, but I guess
there would be a certain amount of work in checking.

I just picked a directory with your name on it to get your attention ;-)
Code hack is at end. Nice that Python makes it so easy, for which THANKS ;-)

[12:18] D:\Python-2.1\Demo\tkinter\guido>casecheck.py *.py
---- AttrDialog.py ----
{'Button': 1, 'button': 10}
{'canvas': 4, 'Canvas': 1}
{'stringoption': 6, 'StringOption': 6}
{'ReadonlyOption': 6, 'readonlyoption': 6}
{'E': 3, 'e': 7}
{'enumoption': 6, 'EnumOption': 6}
{'None': 12, 'NONE': 2}
{'label': 5, 'Label': 2}
{'TOP': 1, 'top': 7}
{'Dialog': 6, 'dialog': 17}
{'Tk': 1, 'tk': 4}
{'Menu': 1, 'menu': 3}
{'Frame': 2, 'frame': 13}
{'booleanoption': 6, 'BooleanOption': 6}
{'Option': 5, 'option': 10}
{'Entry': 1, 'entry': 3}
---- brownian.py ----
{'canvas': 6, 'Canvas': 1}
{'HEIGHT': 3, 'height': 1}
{'FILL': 2, 'fill': 2}
{'width': 1, 'WIDTH': 3}
---- canvasevents.py ----
{'Canvas': 2, 'canvas': 20}
{'Pile': 3, 'pile': 9}
{'group': 19, 'Group': 5}
{'Bottom': 2, 'bottom': 2}
{'Demo': 2, 'demo': 7}
{'Object': 5, 'object': 11}
---- dialog.py ----
{'pack': 9, 'Pack': 1}
{'TOP': 1, 'top': 4}
---- electrons.py ----
{'canvas': 2, 'Canvas': 1}
{'Tk': 1, 'tk': 8}
---- hanoi.py ----
{'canvas': 2, 'Canvas': 1}
{'Tk': 1, 'tk': 11}
---- hello.py ----
{'Button': 1, 'button': 4}
---- imagedraw.py ----
---- imageview.py ----
{'label': 2, 'Label': 1}
---- kill.py ----
{'Y': 1, 'y': 4}
{'kill': 6, 'Kill': 2}
{'Menu': 1, 'menu': 4}
{'label': 4, 'Label': 1}
{'frame': 21, 'Frame': 4}
---- listtree.py ----
{'Tk': 1, 'tk': 5}
---- ManPage.py ----
{'ManPage': 2, 'manpage': 3}
{'Tk': 1, 'tk': 2}
---- mbox.py ----
{'MH': 1, 'mh': 6}
{'Tk': 1, 'tk': 6}
---- MimeViewer.py ----
{'MH': 1, 'mh': 2}
{'tk': 3, 'Tk': 1}
{'Frame': 3, 'frame': 14}
---- newmenubardemo.py ----
{'menu': 4, 'Menu': 4}
{'app': 1, 'App': 2}
---- optionmenu.py ----
---- paint.py ----
---- rmt.py ----
{'y': 9, 'Y': 1}
{'tk': 4, 'Tk': 1}
{'menu': 1, 'Menu': 2}
{'x': 9, 'X': 1}
{'text': 1, 'Text': 1}
---- ShellWindow.py ----
{'Tk': 1, 'tk': 3}
{'SIGINT': 1, 'sigint': 2}
{'sigquit': 1, 'SIGQUIT': 1}
{'sigterm': 2, 'SIGTERM': 1}
{'SIGKILL': 1, 'sigkill': 2}
---- solitaire.py ----
{'window': 1, 'Window': 2}
{'Canvas': 2, 'canvas': 15}
{'Deck': 2, 'deck': 6}
{'stack': 11, 'Stack': 4}
{'background': 2, 'BACKGROUND': 4}
{'group': 17, 'Group': 5}
{'Card': 2, 'card': 67}
{'N': 1, 'n': 4}
{'color': 4, 'COLOR': 5}
---- sortvisu.py ----
{'label': 3, 'Label': 2}
{'right': 20, 'RIGHT': 1}
{'Canvas': 2, 'canvas': 7}
{'Array': 4, 'array': 96}
{'Y': 2, 'y': 4}
{'x': 7, 'X': 14}
{'Frame': 4, 'frame': 6}
{'left': 19, 'LEFT': 1}
{'width': 2, 'WIDTH': 3}
---- svkill.py ----
{'Y': 2, 'y': 2}
{'kill': 6, 'Kill': 2}
{'label': 9, 'Label': 1}
{'Menu': 1, 'menu': 5}
{'frame': 19, 'Frame': 4}
---- switch.py ----
{'Button': 2, 'button': 6}
{'app': 4, 'App': 2}
{'frame': 10, 'Frame': 3}
{'label': 2, 'Label': 1}
---- tkman.py ----
{'Listbox': 1, 'listbox': 9}
{'None': 2, 'NONE': 2}
{'label': 2, 'Label': 1}
{'Frame': 5, 'frame': 9}
{'Entry': 2, 'entry': 9}
---- wish.py ----


_________________________________________________
#casecheck.py
import sys, tokenize, glob, token

symdir={}

def tokeneater(type, tokstr, start, end, line):
    if (type==token.NAME):
	TOKSTR = tokstr.upper()		#should show up for this file
        if symdir.has_key(TOKSTR):
            d = symdir[TOKSTR]
            if d.has_key(tokstr):
                d[tokstr] += 1
            else:
                d[tokstr] = 1
        else:
            symdir[TOKSTR]={ tokstr:1 }
        
for fileglob in sys.argv[1:]:
    for filename in glob.glob(fileglob):
        symdir={}
        print '----',filename,'----'
        tokenize.tokenize(open(filename).readline, tokeneater)

        for key in symdir.keys():
            if len(symdir[key]) > 1:
                print symdir[key]




More information about the Python-list mailing list