struct.pack returns nothing [3]

skip at pobox.com skip at pobox.com
Mon Mar 19 19:15:37 EDT 2007


    Andrés> I'm using the example of the site
    Andrés> http://docs.python.org/lib/module-struct.html : 

    Andrés> import struct
    Andrés> pack('hhl', 1, 2, 3)

    Andrés> I should get:
    >>>> '\x00\x01\x00\x02\x00\x00\x00\x03'
    Andrés> I get an empty line, a '\n': 
    >>>> 
    >>>> _

Try

    import struct
    struct.pack('hhl', 1, 2, 3)

or

    from struct import pack
    pack('hhl', 1, 2, 3)

instead.

Skip




More information about the Python-list mailing list