preferring [] or () in list of error codes?
Mel
mwilson at the-wire.com
Sat Jun 13 11:25:27 EDT 2009
Gunter Henriksen wrote:
[ ... ]
> I guess to me, fundamentally, the interpretation of
> tuple as a sequence whose elements have semantic meaning
> implicitly defined by position is a relatively abstract
> intrepretation whose value is dubious relative to the
> value of immutability, since it seems like a shortcut
> which sacrifices explicitness for the sake of brevity.
The immutability makes it easier to talk about the semantic meanings. After
you do
> event_timestamp = (2009, 06, 04, 05, 02, 03)
there's nothing that can happen to the tuple to invalidate
> (year, month, day, hour, minute, second) = event_timestamp
even though, as you say, there's nothing in the tuple to inform anybody
about the year, month, day, ... interpretation.
And of course there's nothing in a C struct object that isn't in the
equivalent Python tuple. The difference is that the C compiler has arranged
all the outside code that uses the struct object to use it in the correct
way. The only object I've found in Python that truly replaces a struct
object in C is a dict with string keys -- or an object that uses such a dict
as its __dict__.
Mel.
More information about the Python-list
mailing list