Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #95275
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| 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 | Wed, 12 Aug 2015 11:06:03 +0200 |
| Organization | Decebal Computing |
| Lines | 28 |
| Message-ID | <87h9o46flw.fsf@Equus.decebal.nl> (permalink) |
| Mime-Version | 1.0 |
| Content-Type | text/plain |
| Injection-Info | mx02.eternal-september.org; posting-host="528adfd6ad074c92fdc6a7f8fb9e23d8"; logging-data="12714"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+XkGdeGsNeFAz6YtB2Wgt/IiQo3RriZeM=" |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
| X-Homepage | http://www.decebal.nl/ |
| Cancel-Lock | sha1:8HRGnfI+J3t3QRr3zdY67Gfksr8= sha1:fqNYZOVc0j9e/s5qffHTr6fWVeQ= |
| Xref | csiph.com comp.lang.python:95275 |
Show key headers only | View raw
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