Greetings:

I have a function that computes the checksum of an integer, including or 
excluding digits in the computation based on the content of a mask string.  For 
example, 

    cksum(123456789, '***...***')

will do its computation on 123789, masking out the three non-significant 
digits.  

My question concerns assigning the value of the mask string.  The class that 
defines the function also pre-defines several masks, say '*********', 
'***...***', and '......***'.  The masks have names: 'all', 'first-last', 
'last'. Of these, 'all' is the most commonly used.  The user may select one of 
these masks, or may supply their own, arbitrary value. Further, the user can 
choose to add their value to the group of pre-defines, and reuse that value 
later in the session.  (The user-defined mask is not saved between sessions; no 
permanent storage is required.)

So far, this structure looks like a dictionary.  However, the user also wants 
to access the group of pre-defined masks as if they were elements of a list: 

     masks[0] returns '*********' 
     masks[1] returns '***...***'

and so on.  To make matters even more complex, if the user does not specify a 
mask to use, the function should use the mask employed in the previous 
invocation, defaulting to masks[0] if this is the first invocation.  Finally, 
the user can set a mask as 'default', which essentially marks a mask as 'last 
used' without invoking the function.  

Is there a derived type or data structure in existence that implements these 
capabilities (in descending order of importance?

    1. Access by name         (dict)
    2. Access by position     (list)
    3. Addition of new items  (dict, list)
    4. Set a 'last used' item (??????)
    5. Set a 'default' item   (dict???)

Thanks in advance for your help.  

Regards,
 
Barry
[EMAIL PROTECTED]
541-302-1107
________________________
We who cut mere stones must always be envisioning cathedrals.
-Quarry worker's creed


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to