Emanuele D'Arrigo wrote: > Gary, thanks for your reply: your explanation does pretty much answer > my question. One thing I can add however is that it really seems that > non-alphanumeric characters such as the forward slash make the > difference, not just the number of characters. I.e.
(Actually, we had this thread last week.) It's a question of strings that might be Python names. Every line of code that looks up a name in a namespace (e.g. global symbols, instance attributes, class attributes, etc.) needs a string containing the name. This optimization keeps Python data space from filling up with names. The same thing happens with small, common, integers. [ ... ] > I just find it peculiar more than a nuisance, but I'll go to the > blackboard and write 100 times "never compare the identities of two > immutables". Thank you all! The rule is to know the operations, and use the ones that do what you want to do. `is` and `==` don't do the same thing. Never did, never will. <sarcasm> Python 2.5.2 (r252:60911, Oct 5 2008, 19:24:49) [GCC 4.3.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> a=3 >>> b=0 >>> a+b == a-b True >>> b=1 >>> a+b == a-b False At this point, someone says 'Eek'. But why? `+` and `-` never were the same operation, regardless of a coincidence or two. </sarcasm> Mel. -- http://mail.python.org/mailman/listinfo/python-list