comparing all values of a list to regex

Delaney, Timothy tdelaney at avaya.com
Sun Sep 29 20:31:39 EDT 2002


> From: Alex Martelli [mailto:aleax at aleax.it]
> 
> Delaney, Timothy wrote:
>         ...
> >> > elif matches != len(alist):
> >> >     match_list = match_some
> >> > 
> >> > match_list.append(alist)
> >> 
> >> Yes, choosing a list first and then appending to the chosen
> >> list is nicer, but you cannot do that within the original
> >> specs (for all I know the match_some list might grow
> >> unbearably large over time, in this case).
> > 
> > Hmm - why not? Ignoring that the original specs didn't 
> actually *have*
> > that case, 
> 
> Not ignoring it, one would think the specs must be to do nothing
> special in that case.
> 
> If your program was specified to "append to list1 if the time is
> exactly 11:22:33, to list2 if the time is exactly 17:26:35", would
> you consider it reasonable to make your program appent to list3
> if it's any other time of day?

Well, of course. I thought you were talking about the implementation (since
you yourself mentioned the unspecified case) - not the conformance to the
specs.

Not having that case in the specs is not a cause for simply ignoring it.
What you should instead to is get an explicit statement of what is to occur
in that case into the specs (e.g. if more than one match is found, but not
everything, the line should be ignored).

It was an *incomplete* specification, which would require querying by the
(usually) system engineer in order to produce complete specifications. If
such specs made it to a developer I should bloody hope that they would say
"and what should I do in this case?".

Tim Delaney




More information about the Python-list mailing list