case-sensitivity

Ron Adam radam2 at tampabay.rr.com
Thu Nov 13 18:47:48 EST 2003


On Thu, 13 Nov 2003 14:26:42 GMT, Alex Martelli <aleax at aleax.it>
wrote:

>Ron Adam wrote:
>   ...
>> If an option for case insensitivity were implemented it would just be
>> a matter of doing a lower() function on all source code as a first
>> step in the compile process.  Then case in the source code need not
>> matter, or you could choose to have it matter if that's what you want.
>> It probably isn't that simple.   I haven't looked into the source code
>> far enough yet.   Doing so would probably cause errors in existing
>> programs where names do use same spelling/different case for different
>
>And all uses of standard Python modules such as random and fileinput, 
>which do exactly that sort of thing systematically.

Also it would need to avoid lowering strings and literals too.  


>> Using a case correcting editor is one way of doing it that doesn't
>> change pythons core and lets the programmer choose the behavior they
>> want.
>
>Nope, can't do.  Consider:
>
>>>> import random
>>>> x=random.Random()
>>>> y=random.random()
>
>now x and y are two VERY different things:
>
>>>> x
><random.Random object at 0x81aa9d4>

Is this very common,  I tried to find other examples of this.   Is
there another way to get a base class of an object?  Is this different
for different modules, or is it a standard?


>>>> y
>0.93572104869999828
>
>...but how would a poor "case correcting editor" distinguish them...?
>

Something like this where 'word' is a possible name:

if word matches any name in both spelling and case:
	pass          # leave it alone
elif word matches a single name,  but case is incorrect:
	correct case
elif word matches several names spelled the same, but neither in
correct case:
	give a hint
	get choice from hint 
 

>Such a smart editor might HELP a little by SUGGESTING a case-correction
>when it appears unambiguous, even just for standard modules and the
>functions therein.  Maybe a menu-command for "suggest case corrections
>if any" WOULD be helpful in IDLE, and offer good cost/benefit ratio as
>a fun, not-too-terribly-hard project reducing human misery a bit...:-).
>
>
>Alex

I think so,  especially for people first starting out or switching
from another language.  

I think there could different levels of correction/suggestion modes.

None   ==  turn it off

Polite  ==  suggest choices if the case doesn't match,  but don't
actually correct anything.

Assertive == Correct when it's obvious to do so,  and suggest when
there is more than one choice.


What one would choose would be dependant on how well they know python
and how accurate they type. 


_Ron Adam






More information about the Python-list mailing list