home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.os.linux.misc      Linux-specific topics not covered by oth      135,536 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 134,684 of 135,536   
   Rich to c186282@nnada.net   
   Re: Ridiculous Online Programming "Advic   
   12 Jan 26 05:57:42   
   
   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)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca