Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #94982
| From | Cecil Westerhof <Cecil@decebal.nl> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Linux script to get most expensive processes |
| Date | 2015-08-05 01:14 +0200 |
| Organization | Decebal Computing |
| Message-ID | <87k2tahcir.fsf@Equus.decebal.nl> (permalink) |
| References | <87twsehkmk.fsf@Equus.decebal.nl> <mailman.1218.1438721578.3674.python-list@python.org> <87pp32hhbr.fsf@Equus.decebal.nl> <mailman.1219.1438725612.3674.python-list@python.org> |
On Wednesday 5 Aug 2015 00:00 CEST, MRAB wrote:
>> I amended the code to work with linux and linux2:
>> ========================================================================
>> accepted_params = { 'pcpu', 'rss', 'size', 'time', 'vsize', }
>> accepted_platforms = { 'linux', 'linux2', } current_platform =
>> sys.platform max_line_length = 200 no_of_lines = 8 # One extra for
>> the heading
>>
>> is_good_platform = False for platform in accepted_platforms: if
>> platform == current_platform: is_good_platform = True break if not
>> is_good_platform: raise Exception('Got an incompatiple platform:
>> {0}'. format(current_platform))
>> ========================================================================
>>
> Doesn't that 'for' loop do the same as:
>
> is_good_platform = current_platform in accepted_platforms
You are right. Not very smart. Especially because I use the ‘in’ a
little later.
It now is:
========================================================================
if not current_platform in accepted_platforms:
raise Exception('Got an incompatiple platform: {0}'.
format(current_platform))
========================================================================
And I do not need is_good_platform anymore.
--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Linux script to get most expensive processes Cecil Westerhof <Cecil@decebal.nl> - 2015-08-04 22:19 +0200
Re: Linux script to get most expensive processes Emile van Sebille <emile@fenx.com> - 2015-08-04 13:52 -0700
Re: Linux script to get most expensive processes Cecil Westerhof <Cecil@decebal.nl> - 2015-08-04 23:30 +0200
Re: Linux script to get most expensive processes MRAB <python@mrabarnett.plus.com> - 2015-08-04 23:00 +0100
Re: Linux script to get most expensive processes Cecil Westerhof <Cecil@decebal.nl> - 2015-08-05 01:14 +0200
Re: Linux script to get most expensive processes Emile van Sebille <emile@fenx.com> - 2015-08-04 15:12 -0700
Re: Linux script to get most expensive processes Cecil Westerhof <Cecil@decebal.nl> - 2015-08-05 01:17 +0200
Re: Linux script to get most expensive processes Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-08-05 12:56 +0200
Re: Linux script to get most expensive processes Laura Creighton <lac@openend.se> - 2015-08-06 06:06 +0200
csiph-web