Re: Check for regular expression in a list

2017-05-26 Thread Peter Otten
Jussi Piitulainen wrote: > Surely that should be: > > if not 'firefox' in (i.name() for i in process_iter()): > > And that again should be: > > if any((i.name() == 'firefox') for i in process_iter()): The previous one certainly looks better than this, particularly if you move the

Re: Check for regular expression in a list

2017-05-26 Thread Cecil Westerhof
On Friday 26 May 2017 14:25 CEST, Jussi Piitulainen wrote: > Rustom Mody writes: > >> On Friday, May 26, 2017 at 5:02:55 PM UTC+5:30, Cecil Westerhof wrote: >>> To check if Firefox is running I use: >>> if not 'firefox' in [i.name() for i in list(process_iter())]: >>> >>>

Re: Check for regular expression in a list

2017-05-26 Thread Rustom Mody
On Friday, May 26, 2017 at 5:55:32 PM UTC+5:30, Jussi Piitulainen wrote: > Rustom Mody writes: > > > On Friday, May 26, 2017 at 5:02:55 PM UTC+5:30, Cecil Westerhof wrote: > >> To check if Firefox is running I use: > >> if not 'firefox' in [i.name() for i in list(process_iter())]: > >> > >>

Re: Check for regular expression in a list

2017-05-26 Thread Jussi Piitulainen
Jussi Piitulainen writes: > Or use a regex match if the condition becomes more complex. Even then, > there is re.match to attemp a match at the start of the string, which > helps to keep the expression simple. Soz: attemp' a match. -- https://mail.python.org/mailman/listinfo/python-list

Re: Check for regular expression in a list

2017-05-26 Thread Jussi Piitulainen
Rustom Mody writes: > On Friday, May 26, 2017 at 5:02:55 PM UTC+5:30, Cecil Westerhof wrote: >> To check if Firefox is running I use: >> if not 'firefox' in [i.name() for i in list(process_iter())]: >> >> It probably could be made more efficient, because it can stop

Re: Check for regular expression in a list

2017-05-26 Thread Tim Chase
On 2017-05-26 13:29, Cecil Westerhof wrote: > To check if Firefox is running I use: > if not 'firefox' in [i.name() for i in list(process_iter())]: > > It probably could be made more efficient, because it can stop when > it finds the first instance. > > But know I switched to Debian and

Re: Check for regular expression in a list

2017-05-26 Thread Rustom Mody
On Friday, May 26, 2017 at 5:02:55 PM UTC+5:30, Cecil Westerhof wrote: > To check if Firefox is running I use: > if not 'firefox' in [i.name() for i in list(process_iter())]: > > It probably could be made more efficient, because it can stop when it > finds the first instance. > > But know I

Check for regular expression in a list

2017-05-26 Thread Cecil Westerhof
To check if Firefox is running I use: if not 'firefox' in [i.name() for i in list(process_iter())]: It probably could be made more efficient, because it can stop when it finds the first instance. But know I switched to Debian and there firefox is called firefox-esr. So I should use: