473,386 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

accessing individual element in a list.

hi all,could someone clear this up for me. I'm sure it's probably very
simple but I can't seem to get my head round it.....

doing the following
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] u'G' pd.split(',') [u'AGFA-AccuSet v52.3', u'3', u'Windows NT x86'] pd[0]

u'A'

why does pd[1] or pd[0] not return an element from the list instead of
a character from the string? Is split the best method to try and
seperate the individual elements?

Thanks, MW.

Jul 19 '05 #1
2 1349
>>> 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"

Jul 19 '05 #2
the square brackets round the output of split got me. Have plit into a
new list and all works as expeted. Cheers, MW.

Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Darren Smith | last post by:
I am having a great deal of difficulty accessing individual fields generated from a Sql Server 7 view. When I specify the actual field name, I get the error: Microsoft OLE DB Provider for ODBC...
3
by: Martien van Wanrooij | last post by:
I am working on a site with some pages that all have a form that starts with a group of radiobuttons. By default none of the buttons is checked. Before submitting the form there is a validation...
3
by: Christopher Benson-Manica | last post by:
I have an HTMLInputElement in a <td>. I want to access all the <td>'s in the same row as the input element. var tr=theInputElement.parentNode.parentNode; Why isn't the input element's...
6
by: Chris Styles | last post by:
Dear All, I've been using some code to verify form data quite happily, but i've recently changed the way my form is structured, and I can't get it to work now. Originally : The form is...
13
by: Joseph Garvin | last post by:
When I first came to Python I did a lot of C style loops like this: for i in range(len(myarray)): print myarray Obviously the more pythonic way is: for i in my array: print i
7
by: rein.petersen | last post by:
Hey All, I was wondering if there were a way for a script to access it's parent tag without having to use the document.all.tags method which doesn't necessarily identify it if there are more...
7
by: Chuck Anderson | last post by:
I'm pretty much a JavaScript novice. I'm good at learning by example and changing those examples to suit my needs. That said .... ..... I have some select fields in a form I created for a...
3
by: orkonoid | last post by:
Hello, I am having trouble with a Polymorphism issue using container classes. I have a longwinded and shortwinded version of my question: Shortwinded version: How can I store base class...
2
by: ...vagrahb | last post by:
I am having accessing individual rows from a multidimensional array pass to a function as reference CODE: function Declaration int Part_Buffer(char (*buffer),int Low, int High)
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.