Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Is there a more elegant way to handle determing fail status?

Reply
Thread Tools

Re: Is there a more elegant way to handle determing fail status?

 
 
Ian Kelly
Guest
Posts: n/a
 
      01-16-2013
On Tue, Jan 15, 2013 at 4:24 PM, J <(E-Mail Removed)> wrote:
> The exit code determination above works, but it just feels inelegant.
> It feels like there's a better way of implementing that, but I can't
> come up with one that still honors the fail level properly (e.g. other
> solutions will fail on medium, but won't fail properly on medium OR
> higher).


First, instead of having separate variables 'critical_fails',
'high_fails', etc., put them in a collections.Counter 'fails' keyed by
fail level.
Second, make sure those fail level keys are orderable by severity.

Then your check is just:

if fail_priority <= max(fails):
return 1
return 0
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Is there a shorter, more elegant way to write this deep hashlookup statement Dr.Ruud Perl Misc 1 02-21-2013 04:37 PM
Is there a more elegant way to handle determing fail status? J Python 3 01-16-2013 02:55 AM
Re: Is there a more elegant way to handle determing fail status? Oscar Benjamin Python 0 01-15-2013 11:56 PM
There's got to be a more elegant way Lilith C++ 8 09-02-2005 06:34 AM
Is there a more elegant way to do this? Kamilche Python 7 06-29-2004 04:33 AM



Advertisments