Newbie question - array module/fromlist method

Jp Calderone exarkun at intarweb.us
Wed Feb 19 22:48:30 EST 2003


On Wed, Feb 19, 2003 at 07:36:23PM -0800, BrainDead wrote:
> I've found Python documentation and postings that state the 'fromlist'
> function is defined in the array module, HOWEVER, after doing an
> 'import array', I try the following line of code:
>  
> myArray = array.fromlist(whatever)
> 
> and I get an error message that python cannot find fromlist (actual
> error msg:
> 
> AttributeError: 'module' object has no attribute 'fromlist'). 
> 
> I'm sure it's something really lame I've done|haven't done, but I'll
> be damned if I can find it! Can someone throw a CLUE my way? Thanx in
> advance...
> 

    >>> import array
    >>> a = array.array('i')
    >>> a.fromlist(range(100))
    >>> a
    array('i', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
    18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
    37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
    56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
    75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
    94, 95, 96, 97, 98, 99])
    >>>

  Jp

--
There are 10 kinds of people: those who understand binary and those who do
not.
-- 
 up 11 days, 8:28, 4 users, load average: 1.18, 0.87, 0.63
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20030219/3f32f13a/attachment.sig>


More information about the Python-list mailing list