array, a better shell

Neil Cerutti horpner at yahoo.com
Wed Dec 20 08:47:17 EST 2006


On 2006-12-20, bearophileHUGS at lycos.com <bearophileHUGS at lycos.com> wrote:
> For array.array "B" means unsigned char, and such arrays accept to be
> initialized from (str) strings too, this is quite useful:
>
>>>> from array import array
>>>> a = array("B", "hello")
>
> But it seems such capability isn't shared with the append:
>
>>>> a.extend("hello")
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> TypeError: an integer is required

Try:

>>> a.fromstring("hello")

-- 
Neil Cerutti
I have opinions of my own -- strong opinions -- but I don't always agree with
them. --George W. Bush



More information about the Python-list mailing list