case sensitivity and XML

Remco Gerlich scarblac-spamtrap at pino.selwerd.nl
Sun May 21 15:43:12 EDT 2000


Michal Wallace (sabren) wrote in comp.lang.python:
> Not so. In xmllib, you use functions like:
> 
>    start_sometag(self, attrs):
>         pass
> 
> 
> which gets called when the parser sees "<sometag/>"
> Suppose you have this: '<sometag a="lowercase" A="uppercase" a-b="a dash b"/>'
> Then, case sensitive python would yield this dictionary:
> 
>    attrs == {"a":"lowercase", "A":"uppercase", "a-b":"a dash b"}
> 
> No problem whatsoever. Case INsensitive python yields the same dictionary,
> but how do you tell "a" apart from "A"? For example, what is the truth
> value of: attrs["a"] == attrs["A"] ?
> 
> If we assume that attrs["a"] and attrs["A"] are different, then
> someModule.__dict__["A"] != someModule.__dict__["a"]
> 
> Which means someModule.A != someModule.a .. Which means
> python is case sensitive again.

In case insensitive Python, the following would hold
"a" != "A"
somerandomdict["a"] != somerandomdict["A"]
someModule.__dict__["a"] == someModule.__dict__["A"]

IE, I expect that namespaces would use their own dicts, that have the same
interface as normal dicts, but which internally convert keys to one case
(they only have to store string keys anyway). __dict__.keys() would return
the strings in some standard case, I hope.

> One option is to say that python just won't be able to parse some
> XML documents. I think that would be suicide for the language, as
> more and more people and companies start using XML.

It's not just XML, it's any application where "a" is a different string than
"A". That means just about everything. Assuming that "a" would be equal to
"A" in a case insensitive Python is rather silly.


-- 
Remco Gerlich,  scarblac at pino.selwerd.nl
  Murphy's Rules, "Lush profits":
   Metagaming's In the Labyrinth states that a full one-liter wineskin
   costs $2 but an empty one costs $3; you receive $1 profit for downing
   a liter of wine.



More information about the Python-list mailing list