Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #95275
| From | Cecil Westerhof <Cecil@decebal.nl> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Is this a correct way to generate an exception when getting a wrong parameter |
| Date | 2015-08-12 11:06 +0200 |
| Organization | Decebal Computing |
| Message-ID | <87h9o46flw.fsf@Equus.decebal.nl> (permalink) |
I have:
========================================================================
accepted_params = {
'pcpu',
'rss',
'size',
'time',
'vsize',
}
========================================================================
Later I use:
========================================================================
if (to_check != 'all') and not(to_check in accepted_params):
raise Exception('Used illegal parameter: {0}.\n'
'Accepted ones: {1}'
.format(to_check, sorted(accepted_params)))
========================================================================
When using 'all' I want to do the work for all accepted parameters.
;-)
Is this a correct way to do this, or is there a better way?
--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Is this a correct way to generate an exception when getting a wrong parameter Cecil Westerhof <Cecil@decebal.nl> - 2015-08-12 11:06 +0200
Re: Is this a correct way to generate an exception when getting a wrong parameter Chris Angelico <rosuav@gmail.com> - 2015-08-12 19:25 +1000
Re: Is this a correct way to generate an exception when getting a wrong parameter Peter Otten <__peter__@web.de> - 2015-08-12 11:33 +0200
Re: Is this a correct way to generate an exception when getting a wrong parameter Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-08-12 11:43 +0100
Re: Is this a correct way to generate an exception when getting a wrong parameter Bernd Waterkamp <Bernd-Waterkamp@web.de> - 2015-08-12 18:42 +0200
csiph-web