Re: Encapsulation, inheritance and polymorphism

Discussion in 'Python' started by Tim Chase, Jul 17, 2012.

  1. Tim Chase

    Tim Chase Guest

    On 07/17/12 12:24, Terry Reedy wrote:
    > On 7/17/2012 8:01 AM, Lipska the Kat wrote:
    >> In bash this is laughably trivial
    >>
    >> sort -nr $1 | head -${2:-10}

    >
    > Won't sort work alphabetically and leave the following as is?
    >
    > 1\talpha
    > 11\tbeta
    > 2\tgamma


    Only if Lipska had omitted the "-n" which tells sort to treat
    numbers like numbers.

    For Lipska, you'd want to look into the "csv" module for parsing the
    file easily (specifying '\t' as the delimiter). You can then sort
    and crop as-is, or you can use heapq.nsmallest()

    -tkc
     
    Tim Chase, Jul 17, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Devin Jeanpierre
    Replies:
    0
    Views:
    193
    Devin Jeanpierre
    Jul 17, 2012
  2. Ulrich Eckhardt
    Replies:
    72
    Views:
    987
    Mark Lawrence
    Aug 19, 2012
  3. Terry Reedy
    Replies:
    0
    Views:
    201
    Terry Reedy
    Jul 17, 2012
  4. MRAB
    Replies:
    0
    Views:
    207
  5. Arnaud Delobelle
    Replies:
    0
    Views:
    169
    Arnaud Delobelle
    Jul 18, 2012
Loading...

Share This Page