On 4/13/2023 10:14 PM, avi.e.gr...@gmail.com wrote:
Alan,
Your guess is not quite what I intended.
Something like a C union is just a piece of memory large enough to hold one of
several kinds of content and some way to figure out which is currently in place.
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.
Consider a dumb example. I have an object that holds a temperature and stores
it in say degrees Celsius. There are simple formulas that can convert it to
Fahrenheit or Kelvin or Rankine. So you can create access methods like
get_as_Rankine() but this will only be useful for some programs that know about
the interface.
So what if you had a variable in the class such as supported_formats that
presented something like a list of scales supported using an official set of
names? It may even be possible to get a reference to the function to call to
get that functionality, or perhaps you have one access function that accepts
any argument on the list and delivers what is wanted.
Now you are starting to sound like COM. You ask an object for its
IUnknown interface, and from that interface you can query what other
interfaces it has available. You go on from there.
--
https://mail.python.org/mailman/listinfo/python-list