Python 2.2, creating new types from base types

Peter Milliken peter.milliken at gtech.com
Thu Jan 17 21:38:10 EST 2002


Hi Mark,

I know what you are getting at but my requirements are for exactly a data
type which is a dictionary of dictionaries in the way I have descibed. This
is not an issue of something that hasn't been designed or thought out fully.
I have some data that fits this exact model, there needs to be multiple
instances of the same structure/functionality but with different contents
(hence making it a class or new data structure) and it would be desirable to
use it syntactically exactly as shown in my example (well, a print statement
isn't a wonderful example but it gives the idea :-)).  In fact, I have two
different uses for such a base data structure, so there will be two classes
derived from this one (if I ever get it working :-)).

The second level key (in my application) doesn't have to be an exact match
as you would normally require of a dictionary structure/lookup. My
application requires that if there is no exact match of keys at this level
then the next closest key be used to provide the final value lookup (whether
for comparision or setting etc etc) i.e. there has to be an answer/value no
matter what the input values for the second level key.

Peter

"Mark McEahern" <marklists at mceahern.com> wrote in message
news:mailman.1011308056.20714.python-list at python.org...
> This is somewhat of an orthogonal suggestion, but have you considered
> writing a series of unit tests that verify the functionality/usage you're
> looking for?
>
> In other words, assume your class already existed.  What would usage of it
> look like and what results would it produce?  That's something you can
> (imho, should) codify into a unit test before you even begin
implementation.
>
> Cheers,
>
> // mark
>
>





More information about the Python-list mailing list