really basic question regarding arrays/function output...

Paul McGuire ptmcg at austin.rr._bogus_.com
Sat Jul 1 19:19:58 EDT 2006


"bruce" <bedouglas at earthlink.net> wrote in message
news:mailman.7696.1151792861.27775.python-list at python.org...
> hi...
>
> i have the following test python script.... i'm trying to figure out a
> couple of things...
>
> 1st.. how can i write the output of the "label" to an array, and then how
i
> can select a given element of the array.. i know real basic..
>
I think this is so basic, I'm not sure what you're talking about.  One does
not really "write to an array".  In fact, Python's most natural data
structure is a list, which has many array-like features (there is also an
array module, but since you are asking basic questions, I'm trying to stick
to basic Python).

To append an item to a list, use append.
To graft one list on to the end of another, use += or extend.
To access the i'th element of a list use [i] (indices are zero-based).

This is covered in far better detail in the Python tutorials.  These
fundamental data structures of Python (list, tuple, dict, set, str) are your
fundamental tools when writing Python code, so you should read up on them.

> 2nd.. where can i go to find methods of libxml2dom. i've been looking
using
> google, but can't seem to find a site pointing out the underlying methods,
> which is kind of strange...
>
Try dir and help from the Python interactive command line.  Assuming you
have installed libxml2dom, do this:

import libxml2dom
dir(libxml2dom)
help(libxml2dom)

I see that this module also contains directories for tests and tools, these
may provide you with some usage examples. (The docs directory *is* woefully
brief...)

-- Paul





More information about the Python-list mailing list