[Python-3000] symbols?

Kendall Clark kendall at monkeyfist.com
Tue Apr 11 16:06:02 CEST 2006


On Apr 11, 2006, at 4:18 AM, Greg Ewing wrote:

> The only difference is a syntactic one -- whether you
> write it as 'foo' or something else like :foo.

Yeah, my point about signaling intent. (I forgot about automatic  
interning, so thanks for that reminder.)

>> The other
>> difference (which you may not think essential) is that  strings have
>> lots of methods that are *never* relevant to the uses  one would  
>> put a
>> symbol.
>
> I don't see this as a problem. Strings have a lot of
> methods that I never use on the vast majority of strings
> in my programs, and I don't lose any sleep over it.

Well, there's a diff between majority I mostly don't use and *all  
that are never used*, but YMMV. I don't lose *much* sleep over this. :>

>> Nope, :foo and :Foo are different symbols, no doubt about that.
>
> You miss the point. If you type :Foo when you meant :foo,
> no error occurs at that point.

Right, nor should they since those are different symbols.

> But if you are using a value
> bound to the name foo, referring to it as Foo gives an
> immediate NameError.

Ah, of course. I don't really see that as a benefit here, since the  
joy of symbols is how lightweight they are. Just write one in place  
and go. Enumerations and using variables bound to strings as symbols  
both lose some of that joy since you have to do more work, which  
equates to me to having less fun.

But, obviously, this is one of those things that strikes different  
people differently.

Cheers,
Kendall




More information about the Python-3000 mailing list