Re: accessing individual element in a list.
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

Re: accessing individual element in a list.

From: <simon.dahlbacka@gmail.com>
Date: Fri Jul 01 2005 - 13:39:43 CEST

>>> import wmi
>>> c = wmi.WMI()
>>> for printdriver in c.Win32_PrinterDriver():

... pd = printdriver.Name
>>> print pd

AGFA-AccuSet v52.3,3,Windows NT x86
>>> pd[1] # type(pd) == str
u'G'
>>> pd.split(',')
# split returns a new list, and you do not save it

[u'AGFA-AccuSet v52.3', u'3', u'Windows NT x86']
>>> pd[0]
# pd is still a string
u'A'

so basically, .split is probably the best way to split it up (unless
you want to fiddle with regular expressions, but that seems overkill in
this case), but you need to store the new list. split does not do
anything "inline"
Received on Thu Sep 29 16:41:21 2005