Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #25562
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <arnodel@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.005 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'sys': 0.05; 'bash': 0.07; 'item.': 0.07; 'python': 0.09; 'tab': 0.09; 'cc:addr:python-list': 0.10; 'ascending': 0.16; 'descending': 0.16; 'outputs': 0.16; 'task.': 0.16; 'translation': 0.16; 'wrote:': 0.17; 'followed': 0.20; 'sort': 0.21; 'import': 0.21; 'received:209.85.214.174': 0.21; 'cc:2**0': 0.23; 'solutions.': 0.23; "i've": 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In- Reply-To:1': 0.25; 'message-id:@mail.gmail.com': 0.27; 'asking': 0.32; 'implement': 0.32; 'file': 0.32; "skip:' 20": 0.32; 'print': 0.32; 'yours,': 0.33; 'skip:- 20': 0.34; 'received:google.com': 0.34; 'text': 0.34; 'list': 0.35; "won't": 0.35; 'received:209.85': 0.35; 'something': 0.35; 'stock': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'received:209.85.214': 0.39; 'header:Received:5': 0.40; 'help': 0.40; 'july': 0.60; 'subject:, ': 0.61; 'containing': 0.61; 'kat': 0.91; 'subject:skip:E 10': 0.95 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=HVWUAlCsWyb6i947W0EPTmGV9iveTDMvF10MwReruV8=; b=Vs6jpbcwem7f4kBVf2RmVNBvuCopUCta96h9PBiouaKvP0KOmlxKsxNA0W2CInQ7Ry 9YnUA0VFSVwBXpbIeNqvN1VvHCmjv2V/qJqv2tSbc/1hLIR6ApjiF4FV1e3k3Y7KFyTl evvojrU8Zc0vRjac4igU0kFDMuT95CGIYa62vhKzQ3chPfREY5vZopvADGcScLOQTN+E AISys8F+HeS0QssPH0ms1bRj8FBWN07eamSHGLaD/WCohht8OyH9GluZVpL9i3arsFk/ Urx1o94ZmkHTOMv2sMhP2u1h3ip9ZbEWRZooCto4kaKimpee1+0opConWvEGH4UTNpX6 TyEw== |
| MIME-Version | 1.0 |
| In-Reply-To | <3-WdnYTg0r6XyZjNnZ2dnUVZ7sidnZ2d@bt.com> |
| References | <x_udnUHnRNWDu5jNnZ2dnUVZ8tudnZ2d@bt.com> <3-WdnYTg0r6XyZjNnZ2dnUVZ7sidnZ2d@bt.com> |
| Date | Wed, 18 Jul 2012 11:35:51 +0100 |
| Subject | Re: Encapsulation, inheritance and polymorphism |
| From | Arnaud Delobelle <arnodel@gmail.com> |
| To | Lipska the Kat <lipska@lipskathekat.com> |
| Content-Type | text/plain; charset=UTF-8 |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2264.1342607761.4697.python-list@python.org> (permalink) |
| Lines | 24 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1342607761 news.xs4all.nl 6916 [2001:888:2000:d::a6]:48502 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:25562 |
Show key headers only | View raw
On 17 July 2012 13:01, Lipska the Kat <lipska@lipskathekat.com> wrote:
> Well I've set myself a task.
> I have a text file containing a list of stock items
> each line contains the number in stock followed by a tab followed by the
> name of the item. I need to implement something that reads in the text file
> and outputs the stock list in ascending or descending order of quantity.
>
> Please note I am NOT asking for solutions.
>
> In bash this is laughably trivial
> sort -nr $1 | head -${2:-10}
Here's a Python translation that won't help :)
from sys import argv
print ''.join(sorted(open(argv[1]), key=lambda l:
-int(l.split('\t')[0]))[:10 if len(argv) < 3 else int(argv[2])])
Who said Python was readabl'y yours,
--
Arnaud
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Encapsulation, inheritance and polymorphism Lipska the Kat <lipska@lipskathekat.com> - 2012-07-17 09:45 +0100
Re: Encapsulation, inheritance and polymorphism Devin Jeanpierre <jeanpierreda@gmail.com> - 2012-07-17 06:03 -0400
Re: Encapsulation, inheritance and polymorphism Lipska the Kat <lipska@lipskathekat.com> - 2012-07-17 12:24 +0100
Re: Encapsulation, inheritance and polymorphism Larry Hudson <orgnut@yahoo.com> - 2012-07-18 00:10 -0700
Re: Encapsulation, inheritance and polymorphism Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-07-17 11:30 +0200
Re: Encapsulation, inheritance and polymorphism Lipska the Kat <lipska@lipskathekat.com> - 2012-07-17 12:01 +0100
Re: Encapsulation, inheritance and polymorphism Dave Angel <d@davea.name> - 2012-07-17 07:23 -0400
Re: Encapsulation, inheritance and polymorphism Andrew Berg <bahamutzero8825@gmail.com> - 2012-07-17 06:37 -0500
Re: Encapsulation, inheritance and polymorphism Lipska the Kat <lipska@lipskathekat.com> - 2012-07-17 12:44 +0100
Re: Encapsulation, inheritance and polymorphism Andrew Berg <bahamutzero8825@gmail.com> - 2012-07-17 06:53 -0500
Re: Encapsulation, inheritance and polymorphism Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-07-17 14:35 +0100
Re: Encapsulation, inheritance and polymorphism Lipska the Kat <lipska@lipskathekat.com> - 2012-07-17 15:01 +0100
Re: Encapsulation, inheritance and polymorphism Andrew Berg <bahamutzero8825@gmail.com> - 2012-07-17 09:16 -0500
Re: Encapsulation, inheritance and polymorphism Lipska the Kat <lipska@lipskathekat.com> - 2012-07-17 15:26 +0100
Re: Encapsulation, inheritance and polymorphism Terry Reedy <tjreedy@udel.edu> - 2012-07-17 13:30 -0400
Re: Encapsulation, inheritance and polymorphism Andrew Berg <bahamutzero8825@gmail.com> - 2012-07-17 12:57 -0500
Re: Encapsulation, inheritance and polymorphism Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-07-17 14:18 +0200
Re: Encapsulation, inheritance and polymorphism Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-07-17 14:29 +0100
Re: Encapsulation, inheritance and polymorphism Roy Smith <roy@panix.com> - 2012-07-17 09:52 -0400
Re: Encapsulation, inheritance and polymorphism Lipska the Kat <lipska@lipskathekat.com> - 2012-07-17 15:23 +0100
Re: Encapsulation, inheritance and polymorphism Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-07-17 17:26 +0100
Re: Encapsulation, inheritance and polymorphism Lipska the Kat <lipska@lipskathekat.com> - 2012-07-17 17:46 +0100
Re: Encapsulation, inheritance and polymorphism Terry Reedy <tjreedy@udel.edu> - 2012-07-17 13:07 -0400
Re: Encapsulation, inheritance and polymorphism Lipska the Kat <lipska@lipskathekat.com> - 2012-07-17 20:29 +0100
Re: Encapsulation, inheritance and polymorphism Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-07-17 20:39 +0100
Re: Encapsulation, inheritance and polymorphism Lipska the Kat <lipska@lipskathekat.com> - 2012-07-17 20:52 +0100
Re: Encapsulation, inheritance and polymorphism John Ladasky <john_ladasky@sbcglobal.net> - 2012-08-18 23:05 -0700
Re: Encapsulation, inheritance and polymorphism John Ladasky <john_ladasky@sbcglobal.net> - 2012-08-18 23:05 -0700
Re: Encapsulation, inheritance and polymorphism Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-07-17 18:57 -0400
Re: Encapsulation, inheritance and polymorphism Ethan Furman <ethan@stoneleaf.us> - 2012-07-17 10:29 -0700
Re: Encapsulation, inheritance and polymorphism Chris Angelico <rosuav@gmail.com> - 2012-07-18 04:01 +1000
Re: Encapsulation, inheritance and polymorphism Tim Chase <python.list@tim.thechases.com> - 2012-07-17 12:51 -0500
Re: Encapsulation, inheritance and polymorphism Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-07-17 19:18 +0100
Re: Encapsulation, inheritance and polymorphism Lipska the Kat <lipska@lipskathekat.com> - 2012-07-17 19:36 +0100
Re: Encapsulation, inheritance and polymorphism Andrew Cooper <amc96@cam.ac.uk> - 2012-07-18 01:46 +0100
Re: Encapsulation, inheritance and polymorphism rusi <rustompmody@gmail.com> - 2012-07-17 20:54 -0700
Re: Encapsulation, inheritance and polymorphism Lipska the Kat <lipska@lipskathekat.com> - 2012-07-18 10:06 +0100
Re: Encapsulation, inheritance and polymorphism Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-07-18 14:01 +0200
Re: Encapsulation, inheritance and polymorphism "BartC" <bc@freeuk.com> - 2012-07-19 01:41 +0100
Re: Encapsulation, inheritance and polymorphism Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-18 13:05 +0000
Re: Encapsulation, inheritance and polymorphism Lipska the Kat <lipska@lipskathekat.com> - 2012-07-18 15:40 +0100
Re: Encapsulation, inheritance and polymorphism Chris Angelico <rosuav@gmail.com> - 2012-07-19 01:04 +1000
Re: Encapsulation, inheritance and polymorphism Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-19 01:22 +0000
Re: Encapsulation, inheritance and polymorphism Chris Angelico <rosuav@gmail.com> - 2012-07-19 15:09 +1000
Re: Encapsulation, inheritance and polymorphism Ethan Furman <ethan@stoneleaf.us> - 2012-07-18 08:32 -0700
Re: Encapsulation, inheritance and polymorphism Lipska the Kat <lipska@lipskathekat.com> - 2012-07-18 16:49 +0100
Re: Encapsulation, inheritance and polymorphism Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-19 01:34 +0000
Re: Encapsulation, inheritance and polymorphism rusi <rustompmody@gmail.com> - 2012-07-18 23:09 -0700
Re: Encapsulation, inheritance and polymorphism Lipska the Kat <lipska@lipskathekat.com> - 2012-07-19 09:56 +0100
Re: Encapsulation, inheritance and polymorphism rusi <rustompmody@gmail.com> - 2012-07-19 08:58 -0700
Re: Encapsulation, inheritance and polymorphism Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-19 12:59 +0000
Re: Encapsulation, inheritance and polymorphism Roy Smith <roy@panix.com> - 2012-07-19 09:06 -0400
Re: Encapsulation, inheritance and polymorphism Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-20 07:24 +0000
Re: Encapsulation, inheritance and polymorphism rusi <rustompmody@gmail.com> - 2012-07-20 01:21 -0700
Re: Encapsulation, inheritance and polymorphism Paul Rudin <paul.nospam@rudin.co.uk> - 2012-07-19 18:22 +0100
Re: Encapsulation, inheritance and polymorphism Tim Chase <python.list@tim.thechases.com> - 2012-07-19 13:20 -0500
Re: Encapsulation, inheritance and polymorphism Chris Angelico <rosuav@gmail.com> - 2012-07-20 04:28 +1000
Re: Encapsulation, inheritance and polymorphism Tim Chase <python.list@tim.thechases.com> - 2012-07-19 13:50 -0500
Re: Encapsulation, inheritance and polymorphism Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-20 08:11 +0000
Re: Encapsulation, inheritance and polymorphism Erik Max Francis <max@alcyone.com> - 2012-07-20 02:08 -0700
Re: Encapsulation, inheritance and polymorphism "BartC" <bc@freeuk.com> - 2012-07-20 11:28 +0100
Re: Encapsulation, inheritance and polymorphism Erik Max Francis <max@alcyone.com> - 2012-07-21 14:32 -0700
Re: Encapsulation, inheritance and polymorphism Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-07-23 16:36 +0000
Re: Encapsulation, inheritance and polymorphism Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-07-19 16:47 -0400
Re: Encapsulation, inheritance and polymorphism John Gordon <gordon@panix.com> - 2012-07-19 21:01 +0000
Re: Encapsulation, inheritance and polymorphism Chris Angelico <rosuav@gmail.com> - 2012-07-20 08:20 +1000
Re: Encapsulation, inheritance and polymorphism John Gordon <gordon@panix.com> - 2012-07-19 22:23 +0000
Re: Encapsulation, inheritance and polymorphism Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-20 08:27 +0000
Re: Encapsulation, inheritance and polymorphism Virgil Stokes <vs@it.uu.se> - 2012-07-20 11:05 +0200
Re: Encapsulation, inheritance and polymorphism Hans Mulder <hansmu@xs4all.nl> - 2012-07-20 19:45 +0200
Re: Encapsulation, inheritance and polymorphism Erik Max Francis <max@alcyone.com> - 2012-07-21 14:28 -0700
Re: Encapsulation, inheritance and polymorphism Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-07-20 13:57 -0400
Re: Encapsulation, inheritance and polymorphism Ian Kelly <ian.g.kelly@gmail.com> - 2012-07-19 15:13 -0600
Re: Encapsulation, inheritance and polymorphism Devin Jeanpierre <jeanpierreda@gmail.com> - 2012-07-19 17:30 -0400
Re: Encapsulation, inheritance and polymorphism Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-07-20 10:00 +0100
Re: Encapsulation, inheritance and polymorphism Terry Reedy <tjreedy@udel.edu> - 2012-07-19 02:11 -0400
Re: Encapsulation, inheritance and polymorphism Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-07-23 16:18 +0000
Re: Encapsulation, inheritance and polymorphism Chris Angelico <rosuav@gmail.com> - 2012-07-24 02:15 +1000
Re: Encapsulation, inheritance and polymorphism Robert Miles <robertmiles@teranews.com> - 2012-08-19 00:21 -0500
Re: Encapsulation, inheritance and polymorphism Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-19 09:55 +0100
Re: Encapsulation, inheritance and polymorphism lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-19 12:50 +0100
Re: Encapsulation, inheritance and polymorphism Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-19 13:06 +0100
Re: Encapsulation, inheritance and polymorphism Ethan Furman <ethan@stoneleaf.us> - 2012-07-17 11:43 -0700
Re: Encapsulation, inheritance and polymorphism Devin Jeanpierre <jeanpierreda@gmail.com> - 2012-07-17 15:05 -0400
Re: Encapsulation, inheritance and polymorphism Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-07-17 20:33 +0100
Re: Encapsulation, inheritance and polymorphism Ian <hobson42@gmail.com> - 2012-07-17 19:59 +0100
Re: Encapsulation, inheritance and polymorphism Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-18 12:58 +0000
Re: Encapsulation, inheritance and polymorphism Roy Smith <roy@panix.com> - 2012-07-18 09:07 -0400
Re: Encapsulation, inheritance and polymorphism Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-18 14:31 +0000
Re: Encapsulation, inheritance and polymorphism Dave Angel <d@davea.name> - 2012-07-18 12:33 -0400
Re: Encapsulation, inheritance and polymorphism Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-19 01:23 +0000
Re: Encapsulation, inheritance and polymorphism Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-18 12:43 +0000
Re: Encapsulation, inheritance and polymorphism Grant Edwards <invalid@invalid.invalid> - 2012-07-18 14:34 +0000
Re: Encapsulation, inheritance and polymorphism Lipska the Kat <lipska@lipskathekat.com> - 2012-07-18 15:48 +0100
Re: Encapsulation, inheritance and polymorphism Chris Angelico <rosuav@gmail.com> - 2012-07-19 01:09 +1000
Re: Encapsulation, inheritance and polymorphism Lipska the Kat <lipska@lipskathekat.com> - 2012-07-18 16:36 +0100
Re: Encapsulation, inheritance and polymorphism Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-19 01:14 +0000
Re: Encapsulation, inheritance and polymorphism MRAB <python@mrabarnett.plus.com> - 2012-07-19 02:28 +0100
Re: Encapsulation, inheritance and polymorphism "OKB (not okblacke)" <brenNOSPAMbarn@NObrenSPAMbarn.net> - 2012-07-19 16:52 +0000
Re: Encapsulation, inheritance and polymorphism Andrew Berg <bahamutzero8825@gmail.com> - 2012-07-18 10:00 -0500
Re: Encapsulation, inheritance and polymorphism Lipska the Kat <lipska@lipskathekat.com> - 2012-07-17 13:01 +0100
Re: Encapsulation, inheritance and polymorphism Terry Reedy <tjreedy@udel.edu> - 2012-07-17 13:24 -0400
Re: Encapsulation, inheritance and polymorphism Lipska the Kat <lipska@lipskathekat.com> - 2012-07-17 19:21 +0100
Re: Encapsulation, inheritance and polymorphism MRAB <python@mrabarnett.plus.com> - 2012-07-17 18:43 +0100
Re: Encapsulation, inheritance and polymorphism Tim Chase <python.list@tim.thechases.com> - 2012-07-17 12:56 -0500
Re: Encapsulation, inheritance and polymorphism Arnaud Delobelle <arnodel@gmail.com> - 2012-07-18 11:35 +0100
csiph-web