Tuples -- who needs 'em

darius at connect.com.au darius at connect.com.au
Mon Apr 10 09:16:40 EDT 2000


Martijn Faassen <m.faassen at vet.uu.nl> wrote:
: People tend to use classes for this purpose. You can give a class a public
: interface (enforced or not) with only get_() methods, for instance. That
: gets you just about the same thing as an immutable dictionary would give
: you. Again, a dictionary tends to contain a larger number of homogenous
: objects, while an object tends to contain a smaller number of heterogenous
: objects.

Incidentally, I'd give my right arm for a non-mutable dictionary.  Why?
Because certain methods (in the new module, plus the exec keyword, as classic
examples) won't let me pass anything but a "true" dictionary in as namespace
- and I want to run methods in a namespace they cannot modify.

Would be even better if you could use user classes in those places, but I'd
happily settle for non-mutable dictionaries ;)

KevinL



More information about the Python-list mailing list