does python could support sequence of short or int?

Alex Martelli aleaxit at yahoo.com
Thu Mar 30 18:17:06 CEST 2006


bruno at modulix <onurb at xiludom.gro> wrote:

> momobear wrote:
> > but what about buffer is not be declared in python program, it comes
> > from a C function. and what about I want to treat a string as a short
> > list?
> 
> <OT level='slightly'>
> There are no "short" in Python. An integer is an integer is an integer...
> </OT>

However, standard library module 'array' does let you pack a compact
sequence of integers taking two bytes each.

> > buffer = foobur() // a invoke from C function, it is encapsulated as a
> > string
> > but I want to treat it as a short list.  how can I?
> 
> I think you want the struct package from the standard lib:
> http://www.python.org/doc/2.4.2/lib/module-struct.html

I think he wants array instead.


Alex



More information about the Python-list mailing list