case sensitivity and XML

Michal Wallace (sabren) sabren at manifestation.com
Sun May 21 22:07:23 CEST 2000


On Sun, 21 May 2000, Fredrik Lundh wrote:

> Michal Wallace (sabren) wrote:
> > 11. Given the above, a case-insensitive python cannot parse all
> >     XML documents.
> 
> Q: does __dict__ has to be the same kind of dictionary as you use to
> store XML attributes?  Q: does all *existing* Python implementations
> use the same dictionary type for namespaces and user dictionaries?

I don't know. For sure, you could create some case sensitive dicts and
some case insensitive dicts. In fact, a case insensitive dict is trivial:

>>> import UserDict, string
>>>
>>> class CaseInsensitiveDict(UserDict.UserDict):
>>>     def __setattr__(self, name, value):
>>>         self.data[string.lower(name)] = value
>>>
>>>     def __getattr__(self, name):
>>>         return self.data[string.lower(name)]


But again, consider JPython importing a module from Java. Java is
case sensitive, so javaobject.A has to be different from javaobject.a ..

This is similar to a current behavior in JPython. Suppose I take this class:

public class Case {
   public int main;
   public int main2;

   public static void main(String[] args) {
      System.out.println("hi");
   }
}


and import it into JPython:


JPython 1.1beta4 on java1.2.2 (JIT: symcjit)
Copyright (C) 1997-1999 Corporation for National Research Initiatives
>>> import Case
>>> dir(Case)
['main', 'main2']
>>>


Any guesses what Case.main returns?

>>> Case.main
<java function main at 1270670375>


That poor little int is lost and gone forever... Probably not a
big deal, since it's common practice to use accessor methods..
But what about subclasses versus instances? In java, you could
have a nested class, A... and an instance attribute:  public A a = A();

A case insensitive Jpython would lose the ability to distinguish the
two.


> > Does anyone disagree with the conclusion in line 4? Can we have a case
> > insensitive Python without case-insensitive string comparisons?
> 
> Q: does *namespace* lookups have to use the standard string comparision
> operator?


I say it does, for JPython's sake.

> > Another argument has to do with Java. In java, X and x are different. What
> > does that mean for a case insensitive JPython? That we can only script
> > SOME java objects reliably?
> 
> Q: can you think of any *other* environment that has the same problem?
> Q: how does Visual Basic talk to Java or C++ components over COM?  Q: how
> does PythonWin talk to Visual Basic components? Q: how does SAMBA solve
> the problem with a case-sensitive server and case-insensitive clients?  etc.


I don't know about SAMBA.

Visual Basic doesn't have the same issue. In VB (at least in VBScript)
I create a COM instance like so: 

    Set x = Server.CreateObject("My.Favorite.Component")

Is x.ATTRIBUTE the same as x.attribute? Well, actually, I believe they
are. This has never caused a problem for me.

But the difference is that in VB*, x.A == x.a does not imply that
"A"=="a", whereas in python, it does.


Cheers,

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





More information about the Python-list mailing list