Path: csiph.com!eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!border2.nntp.ams1.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'from:addr:yahoo.co.uk': 0.05; 'mentorship': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'splitting': 0.09; 'python': 0.10; 'jan': 0.11; 'wed,': 0.15; "'from": 0.16; 'i.e.,': 0.16; 'pair.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'wrote:': 0.16; 'string': 0.17; 'language': 0.19; '2015': 0.20; 'aug': 0.20; 'fairly': 0.22; 'lawrence': 0.22; 'am,': 0.23; 'seems': 0.23; 'second': 0.24; 'header:In-Reply-To:1': 0.24; 'sort': 0.25; 'header:User-Agent:1': 0.26; 'header:X-Complaints- To:1': 0.26; 'chris': 0.26; 'earlier': 0.27; 'finally,': 0.27; 'asked': 0.29; 'print': 0.30; 'core': 0.32; 'language.': 0.32; "he's": 0.33; 'sat': 0.33; 'case,': 0.34; 'list': 0.34; 'to:addr :python-list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; '12,': 0.37; 'several': 0.38; 'mailing': 0.38; 'well.': 0.40; 'to:addr:python.org': 0.40; 'mark': 0.40; 'entire': 0.61; 'charset:windows-1252': 0.62; 'subject:skip:A 10': 0.63; 'our': 0.64; 'today': 0.65; 'tutor': 0.66; 'hour': 0.69; 'below:': 0.71; 'counts': 0.81; '10:43': 0.84; 'collection,': 0.84; 'hour,': 0.84; 'pythonistas,': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: AttributeError Date: Wed, 12 Aug 2015 03:46:05 +0100 References: <0baa3bd5-9f80-4d4e-9367-84e2a32d8c70@googlegroups.com> <55CA92BA.7070905@mrabarnett.plus.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: host-78-147-187-165.as13285.net User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1439347585 news.xs4all.nl 2835 [2001:888:2000:d::a6]:34407 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:95269 On 12/08/2015 01:49, Chris Angelico wrote: > On Wed, Aug 12, 2015 at 10:43 AM, Ltc Hotspot wrote: >> Python can pull the hour from the 'From ' line by finding the time and then >> splitting the string a second time using a colon, i.e., From >> stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 2008 >> >> Finally, accumulated the counts for each hour, print out the counts, sorted >> by hour as shown below: > > In that case, you want to sort the entire collection, not a single > key-value pair. > > It seems to me you can do this fairly efficiently with collections.Counter. > Which is exactly what the OP was told on the tutor mailing list several days ago, and he's also asked on the core mentorship list earlier today as well. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence