adjust

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

    #1

    adjust

    Hi,
    How do i right adjust my output using python.I need a output
    something like this:
    DID= 0x01,0x02,0x03, 0x05,0x06,0x07, 0x2B,0x30,0x31, 0x4D,0x4E,
    0x51,0x52,0x53, 0x55,
    minlength= 3, 3, 4, 2, 10, 10, 40, 2, 150, 4, 1,
    2, 2, 1, 2, 1, 6, 3, 17, 1,
    maxlength= 3, 3, 4, 2, 10, 10, 40, 2, 150, 4, 1,
    2, 2, 1, 2, 30, 6, 3, 17, 20

    I am printing from a list, and the values shld print below each id
    like shown.
    Thx

  • Diez B. Roggisch

    #2
    Re: adjust

    saif.shakeel@gm ail.com wrote:
    Hi,
    How do i right adjust my output using python.I need a output
    something like this:
    DID= 0x01,0x02,0x03, 0x05,0x06,0x07, 0x2B,0x30,0x31, 0x4D,0x4E,
    0x51,0x52,0x53, 0x55,
    minlength= 3, 3, 4, 2, 10, 10, 40, 2, 150, 4, 1,
    2, 2, 1, 2, 1, 6, 3, 17, 1,
    maxlength= 3, 3, 4, 2, 10, 10, 40, 2, 150, 4, 1,
    2, 2, 1, 2, 30, 6, 3, 17, 20
    >
    I am printing from a list, and the values shld print below each id
    like shown.
    Thx


    Diez

    Comment

    • Michael Hoffman

      #3
      Re: adjust

      saif.shakeel@gm ail.com wrote:
      How do i right adjust my output using python.

      minlength= 3, 3, 4, 2, 10, 10, 40, 2, 150, 4, 1,
      2, 2, 1, 2, 1, 6, 3, 17, 1,
      Something like:
      >>def write_sequence( label, sequence):
      .... expanded_text = ",".join("% 4d" % item for item in sequence)
      .... print "%s=%s" % (label, expanded_text)
      ....
      >>write_sequenc e("minlength" , minlength)
      minlength= 3, 3, 4, 2, 10, 10, 40, 2, 150, 4, 1

      Completing with a trailing ",", using the entire sequence instead of a
      subset, and dealing with your hex constants are left as an exercise to
      the reader.
      --
      Michael Hoffman

      Comment

      • A.T.Hofkamp

        #4
        Re: adjust

        On 2007-04-24, saif.shakeel@gm ail.com <saif.shakeel@g mail.comwrote:
        Hi,
        How do i right adjust my output using python.I need a output
        something like this:
        DID= 0x01,0x02,0x03, 0x05,0x06,0x07, 0x2B,0x30,0x31, 0x4D,0x4E,
        0x51,0x52,0x53, 0x55,
        minlength= 3, 3, 4, 2, 10, 10, 40, 2, 150, 4, 1,
        2, 2, 1, 2, 1, 6, 3, 17, 1,
        maxlength= 3, 3, 4, 2, 10, 10, 40, 2, 150, 4, 1,
        2, 2, 1, 2, 30, 6, 3, 17, 20
        >
        I am printing from a list, and the values shld print below each id
        like shown.
        Thx
        Collect the data to print in rows underneath each other in a list for each
        column, decide how wide each column should become, and finally, print out each
        line using the computed widths.

        Albert

        Comment

        Working...