struct.pack returns nothing

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • andmarti@gmail.com

    #1

    struct.pack returns nothing

    If I build a strict with:

    import struct
    print struck.pack ('i', 1)

    it returns a '\n'.
    What's wrong with it???
    :(

    --
    Andrés M.
    ---------------------------------------------
  • Alex Martelli

    #2
    Re: struct.pack returns nothing

    <andmarti@gmail .comwrote:
    If I build a strict with:
    >
    import struct
    print struck.pack ('i', 1)
    >
    it returns a '\n'.
    What's wrong with it???
    :(
    You're trying to print a binary string that's hardly printable as-is.
    Try printing its repr(...) and you'll see all the binary zeros and one
    you crave!-)


    Alex

    Comment

    • AWasilenko@gmail.com

      #3
      Re: struct.pack returns nothing

      On Mar 19, 1:12 am, andma...@gmail. com wrote:
      If I build a strict with:
      >
      import struct
      print struck.pack ('i', 1)
      >
      it returns a '\n'.
      What's wrong with it???
      :(
      >
      --
      Andrés M.
      ---------------------------------------------
      Looks like you spelled struct wrong in the code :)

      Comment

      • andmarti@gmail.com

        #4
        Re: struct.pack returns nothing

        On Sun, Mar 18, 2007 at 10:22:45PM -0700, AWasilenko@gmai l.com wrote:
        On Mar 19, 1:12 am, andma...@gmail. com wrote:
        If I build a strict with:

        import struct
        print struck.pack ('i', 1)

        it returns a '\n'.
        What's wrong with it???
        :(

        --
        Andrés M.
        ---------------------------------------------
        >
        Looks like you spelled struct wrong in the code :)
        You're right. I meant struct there too. heh.
        --
        Andrés M.
        ---------------------------------------------

        Comment

        • andmarti@gmail.com

          #5
          Re: struct.pack returns nothing

          On Sun, Mar 18, 2007 at 10:22:32PM -0700, Alex Martelli wrote:
          <andmarti@gmail .comwrote:
          >
          If I build a strict with:

          import struct
          print struck.pack ('i', 1)

          it returns a '\n'.
          What's wrong with it???
          :(
          >
          You're trying to print a binary string that's hardly printable as-is.
          Try printing its repr(...) and you'll see all the binary zeros and one
          you crave!-)
          Im getting nothing as well.
          The unpack seems to work fine though.

          --
          Andrés M.
          ---------------------------------------------

          Comment

          • Gabriel Genellina

            #6
            Re: struct.pack returns nothing

            En Mon, 19 Mar 2007 02:39:01 -0300, <andmarti@gmail .comescribió:
            On Sun, Mar 18, 2007 at 10:22:32PM -0700, Alex Martelli wrote:
            ><andmarti@gmai l.comwrote:
            >>
            import struct
            print struck.pack ('i', 1)
            >
            it returns a '\n'.
            What's wrong with it???
            :(
            >>
            >You're trying to print a binary string that's hardly printable as-is.
            >Try printing its repr(...) and you'll see all the binary zeros and one
            >you crave!-)
            >
            Im getting nothing as well.
            The unpack seems to work fine though.
            Works fine for me:

            pyimport struct
            pyprint repr(struct.pac k('i',1))
            '\x01\x00\x00\x 00'

            --
            Gabriel Genellina

            Comment

            Working...