Problem listing services with wmi

Larry Bates lbates at syscononline.com
Mon May 16 17:36:36 EDT 2005


I guess I was wrong and it does work, but from Python Style Guide:

Whitespace in Expressions and Statements
  Pet Peeves

    Guido hates whitespace in the following places:

<snip>
    - Immediately before the open parenthesis that starts the argument
      list of a function call, as in "spam (1)".  Always write
      this as "spam(1)".

<end snip>

-Larry

Jean-Sébastien Guay wrote:
> Hello Larry,
> 
>> Might not be the problem but try without the leading
>> spaces before your method calls.
>>
>> for s in c.Win32_Service ():
>>
>> should be
>>
>> for s in c.Win32_Service():
>>  
>>
> 
> No change. For reference, the reason I know it's the c.Win32_Service()
> call that's throwing the exception is that if I try to run this :
> 
> import wmi
> import pythoncom
> 
> pythoncom.CoInitialize()
> c = wmi.WMI()
> services = c.Win32_Service()
> for s in services :
>  print s.Caption, s.State
> 
> the exception gets thrown on the "services = ..." line.
> 
> Out of curiosity, is there any reason why whitespace between the method
> name and parameter list parentheses isn't good? Because the code I
> posted before was copy-pasted from Tim Golden's site
> (http://tgolden.sc.sabren.com/python/wmi.html) and the spaces were there.
> 
> Thanks,
> 
> J-S
> 



More information about the Python-list mailing list