Case-sensitivity: why -- or why not? (was Re: Damnation!)

Michal Wallace (sabren) sabren at manifestation.com
Sun May 21 15:01:07 EDT 2000


On Sun, 21 May 2000, Eric Hagemann wrote:


> This is a major point that drew me to Python and away from Perl. In Perl if
> you use a variable on the right of an equal sign before it is used on the
> left, Perl creates it for you and initializes it to the most logical form of
> Null/0/"".  I do not know how many hours I have spent looking for errors
> induced by these kinda of 'benifits' of the langauge.  Python on the other
> hand puts up a fit if the varable is not first defined by having it on the
> left side of the equal sign.  That cuts way down on the errors -- especialy
> subtle ones. Score one for Python !


ummmm... in Perl: 

      use strict;
      $x = 1;

yields: Global symbol "$x" requires explicit package name at - line 2.


to fix it:

      use strict;
      my $x;

      $x = 1;



> As far as typing help in the IDE has anyone notice the VB editor lately.  I
> was doing a bit of VB coding  and noticed that as I created variables in the
> editor and used the same spelling but different case the editor would 'go
> back' to a previously same named variable in the same funtion and modify
> it's case as well (spoooooooky!) but perhaps a mode like that (which would
> probably cause havoc to some programmers -- so make it optional) could be an
> enabler for the young and tender.

Some VB-style editors (like the one in MS-Access) will do two things:

1. If you edit the topmost use of the variable in the file, it changes
   the case on all subsequent variables.

2. If you edit any other use, it changes whatever you just typed to
   match the case of the previous use.


This still doesn't help the x = X() problem though... Any code that did
this would wipe out the class X:

>>> class X:
...    pass
...
>>> X = X()
>>> X
<__main__.X instance at a7e80>
>>> X()
Traceback (innermost last):
  File "<stdin>", line 1, in ?
AttributeError: no __call__ method defined
>>>


(although.. come to think of it.. if X is in its own namespace, this wouldn't
happen, because you'd have x = namespace.X() ...)


> As a quick thought, how about the IDE undelining each _new_ variable as
> defined in the code.  Perhaps seeing a visual indication of variable
> creation might help this problem

This makes sense!

You know... Somebody ought to just implement a tool-based solution
NOW, and try it out in a usability test... Then we can have a solution
long before comes around. :)

Maybe a simple rule in IDLE:

   IF the file already has mixed case when you load it, don't mess with
   the cases..

   ELSIF a case sensitivity training wheel flag is set (on by default), 
   do cases the VB way..

   ELSE ignore case.

Cheers,

- Michal
-------------------------------------------------------------------------
http://www.manifestation.com/         http://www.linkwatcher.com/metalog/
-------------------------------------------------------------------------





More information about the Python-list mailing list