Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'bash': 0.07; 'item.': 0.07; 'ok.': 0.07; 'python': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'tab': 0.09; 'terry': 0.09; '2.7.3': 0.16; 'ascending': 0.16; 'descending': 0.16; 'message-id:@dough.gmane.org': 0.16; 'outputs': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'task.': 0.16; 'wrote:': 0.17; 'jan': 0.18; 'followed': 0.20; 'sort': 0.21; 'solutions.': 0.23; "i've": 0.23; 'linux': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User- Agent:1': 0.26; 'leave': 0.26; 'am,': 0.27; 'is?': 0.27; 'header:X -Complaints-To:1': 0.28; 'code': 0.31; 'asking': 0.32; 'implement': 0.32; 'problem.': 0.32; 'file': 0.32; 'could': 0.32; 'ubuntu': 0.33; 'to:addr:python-list': 0.33; 'text': 0.34; 'done': 0.34; 'list': 0.35; "won't": 0.35; 'something': 0.35; 'received:org': 0.36; 'but': 0.36; 'stock': 0.36; 'subject:: ': 0.38; 'brief': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'easy': 0.60; 'subject:, ': 0.61; 'containing': 0.61; 'more.': 0.62; 'taking': 0.65; 'believe': 0.69; 'received:fios.verizon.net': 0.84; 'inefficient': 0.91; 'kat': 0.91; 'subject:skip:E 10': 0.95 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Encapsulation, inheritance and polymorphism Date: Tue, 17 Jul 2012 13:24:25 -0400 References: <3-WdnYTg0r6XyZjNnZ2dnUVZ7sidnZ2d@bt.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-173-75-251-66.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 In-Reply-To: <3-WdnYTg0r6XyZjNnZ2dnUVZ7sidnZ2d@bt.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 41 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1342545888 news.xs4all.nl 6842 [2001:888:2000:d::a6]:50568 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:25516 On 7/17/2012 8:01 AM, Lipska the Kat wrote: > On 17/07/12 09:45, Lipska the Kat wrote: >> Pythoners >> >> Python 2.7.3 >> Ubuntu Linux 12.04 LTS >> >> I've been taking a brief look at Python. >> > > snip > > 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. Nice problem. Easy but non-trivial. > Please note I am NOT asking for solutions. Ok. With some inefficient redundancy, I believe it could be done in one line in Python. Better code would take a few more. > 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 -- Terry Jan Reedy