From: rich@example.invalid   
      
   c186282 wrote:   
   > On 1/11/26 15:31, Rich wrote:   
   >> c186282 wrote:   
   >>> On 1/11/26 02:31, rbowman wrote:   
   >>>> On Sat, 10 Jan 2026 20:14:49 -0500, c186282 wrote:   
   >>>>   
   >>>>> def AmRunning(ss) :   
   >>>>> return os.popen("ps ax").read().count(ss) # get, unwrap, count   
   >>>>   
   >>>> .bashrc   
   >>>> AmRunning() {   
   >>>> ps aux | grep $1 | wc -l   
   >>>> }   
   >>>   
   >>> "aux" creates a much larger text.   
   >>>   
   >>> And, for this purpose, no 'grep' is needed   
   >>> or desired.   
   >>   
   >> Your .count() is implicity a "grep" in that to count it has to see if   
   >> "ss" exists on the line. So the function is still there, even if it is   
   >> hidden behind the abstraction.   
   >   
   > Exactly, ergo there's no point in effectively   
   > grepping twice. 'Count()' also nicely adds up   
   > the number of matching instances.   
      
   You miss the point (as usual). The grep is required for the shell   
   script version because wc does not include any implicit 'grepping'.   
      
   And the effect of the 'grep' is still present, just not as explicitly,   
   in the python version.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|