Yes, Dave, there are many data structures that can be used to maintain a list of output types the class claims to support. Dictionaries have the interesting property that you can presumably have a value that holds a member function to access the way the key specifies.
Ideally, the order is not important for what I am looking for. Generally, I would think that any class like the ones I have been discussing, would want to broadcast a fairly short list of output types it would support. Of course, if you look at my date example, the list could be quite big but if you simply use something like strftime() for many of the formats, perhaps you may not need to list all possible ones. Any valid format could be accepted as an argument and passed to such a utility function. Your dictionary might simply store some commonly used formats known to work. But I repeat. This is not a serious request. I know how to build limited functionality like this if I ever want it, but wonder if anyone has ever created a proposal for some protocols and perhaps helpers like say an embedded object that handles aspects of it once you have initialized your dictionary and also handles requests to show part of what is stored for any shoppers wondering if you are compatible with their needs. -----Original Message----- From: Python-list <python-list-bounces+avi.e.gross=gmail....@python.org> On Behalf Of 2qdxy4rzwzuui...@potatochowder.com Sent: Thursday, April 13, 2023 10:27 PM To: python-list@python.org Subject: Re: RE: Weak Type Ability for Python On 2023-04-13 at 22:14:25 -0400, avi.e.gr...@gmail.com wrote: > I am looking at a data structure that is an object of some class and > stores the data in any way that it feels like. But it may be a bit of > a chameleon that shows one face or another as needed. I can write code > now that simply adds various access methods to the class used and also > provides a way to query if it supports some interfaces. Python dicts act mostly like hash tables. All by themselves, hash tables are unordered (and in return for giving up that order, you get O(1) access to an item if you know its key). But when you ask a Python dict for the keys, you always get them in the same order, skipping those that have been deleted since the last time you asked, and appending the new keys to the end of the list in the order in which you added them. There's your chameleon. -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list