Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #95264
| Path | csiph.com!goblin1!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <kirotawa@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.011 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'method.': 0.05; 'cc:addr :python-list': 0.09; 'fname': 0.09; 'tuple': 0.09; 'everyone,': 0.15; 'handle:': 0.16; 'wrote:': 0.16; 'attribute': 0.18; 'creates': 0.18; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'aug': 0.20; 'assign': 0.22; 'tuples': 0.22; 'cc:no real name:2**0': 0.22; 'code,': 0.23; 'header:In- Reply-To:1': 0.24; 'skip:- 40': 0.25; 'error': 0.27; 'equivalent': 0.27; 'raw': 0.27; 'message-id:@mail.gmail.com': 0.27; 'correct': 0.28; 'be:': 0.29; 'print': 0.30; 'url:mailman': 0.30; 'blog:': 0.30; 'embedded': 0.32; 'url:python': 0.33; 'open': 0.33; 'url:listinfo': 0.34; 'tue,': 0.34; 'file': 0.34; 'handle': 0.34; 'list': 0.34; 'received:google.com': 0.35; 'url:org': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; '12,': 0.37; 'list.': 0.37; 'data': 0.39; 'url:mail': 0.40; 'address': 0.61; 'subject:skip:A 10': 0.63; 'url:tinyurl': 0.67; '12:': 0.84; 'dict()': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=jwObVdmO7XC116NV+0shTgljv5NcV9+Ncg8zt5hZl44=; b=hHNSUte5J2p6coVVvi1Uq+K4PtWqS96haQD2tIXZ78EvP1cjabT5rJCZKDt5FgN6SC Jq0YjeEKmyT0BhCDbyhsx1C9YhH9BfRKqGsPHcviDpbhD9rIJ5f2RlBMxVwxJ4yIAhY5 Xss/50pawoi8T6ArZQsORh+HOwn1cVaKkjg4QVuNOcRBRpYC9UlzJ0ldA4KjdOqN1dEG rw5XwbCVSWcOr0jX6dnLTBcs6Ucu2q9YPpwPYHhGL9mYOQ0dP4OtzWlBhrX8u0eIo7Dj Ha8cVxGoyawZEEN1HJG+YHKceuvxNiwn7Pn6BCge9f0JwwVqPRE3dREVMX44OpNfF1VC X0kw== |
| X-Received | by 10.50.88.8 with SMTP id bc8mr22375434igb.46.1439338620028; Tue, 11 Aug 2015 17:17:00 -0700 (PDT) |
| MIME-Version | 1.0 |
| In-Reply-To | <0baa3bd5-9f80-4d4e-9367-84e2a32d8c70@googlegroups.com> |
| References | <0baa3bd5-9f80-4d4e-9367-84e2a32d8c70@googlegroups.com> |
| From | leo kirotawa <kirotawa@gmail.com> |
| Date | Tue, 11 Aug 2015 21:16:40 -0300 |
| Subject | Re: AttributeError |
| To | Ltc Hotspot <ltc.hotspot@gmail.com> |
| Cc | python-list@python.org |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | quoted-printable |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.89.1439338622.3627.python-list@python.org> (permalink) |
| Lines | 46 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1439338622 news.xs4all.nl 2847 [2001:888:2000:d::a6]:44493 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:95264 |
Show key headers only | View raw
assign using () creates tuple not a list. Tuples have not .sort() method.
correct would be:
ncount = [key,val]
On Tue, Aug 11, 2015 at 9:01 PM, Ltc Hotspot <ltc.hotspot@gmail.com> wrote:
> Hi Everyone,
>
>
> What is the list equivalent to line 12: ncount.sort(reverse=True)
>
>
> count = dict()
> fname = raw_input("Enter file name: ")#
> handle = open (fname, 'r')#
> for line in handle:
> if line.startswith("From "):
> address = line.split()[5]
> line = line.rstrip()
> count[address] = count.get(address, 0) + 1
>
> for key,val in count.items():
> ncount = (key,val)
> ncount.sort(reverse=True)
> print key,val
>
>
> Error message, reads: AttributeError, line 12, below : 'tuple' object has no attribute 'sort'
>
> Raw data code, available at http://tinyurl.com/ob89r9p
> Embedded data code, available at http://tinyurl.com/qhm4ppq
> Visualization URL link, available at http://tinyurl.com/ozzmffy
>
>
> Regards,
> Hal
> --
> https://mail.python.org/mailman/listinfo/python-list
--
----------------------------------------------
LeƓnidas S. Barbosa (Kirotawa)
blog: corecode.wordpress.com
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
AttributeError Ltc Hotspot <ltc.hotspot@gmail.com> - 2015-08-11 17:01 -0700
Re: AttributeError leo kirotawa <kirotawa@gmail.com> - 2015-08-11 21:16 -0300
Re: AttributeError MRAB <python@mrabarnett.plus.com> - 2015-08-12 01:26 +0100
Re: AttributeError Chris Angelico <rosuav@gmail.com> - 2015-08-12 10:49 +1000
Re: AttributeError MRAB <python@mrabarnett.plus.com> - 2015-08-12 01:58 +0100
Re: AttributeError Ltc Hotspot <ltc.hotspot@gmail.com> - 2015-08-11 22:03 -0700
Re: AttributeError MRAB <python@mrabarnett.plus.com> - 2015-08-12 16:12 +0100
Re: AttributeError Denis McMahon <denismfmcmahon@gmail.com> - 2015-08-12 15:50 +0000
Re: AttributeError Ltc Hotspot <ltc.hotspot@gmail.com> - 2015-08-12 09:29 -0700
Re: AttributeError MRAB <python@mrabarnett.plus.com> - 2015-08-12 17:45 +0100
Re: AttributeError Ltc Hotspot <ltc.hotspot@gmail.com> - 2015-08-12 09:57 -0700
Re: AttributeError MRAB <python@mrabarnett.plus.com> - 2015-08-12 18:24 +0100
RE: AttributeError "Clayton Kirkwood" <crk@godblessthe.us> - 2015-08-12 10:31 -0700
Re: AttributeError Emile van Sebille <emile@fenx.com> - 2015-08-12 10:37 -0700
Re: AttributeError Ltc Hotspot <ltc.hotspot@gmail.com> - 2015-08-12 11:35 -0700
Re: AttributeError MRAB <python@mrabarnett.plus.com> - 2015-08-12 19:59 +0100
Re: AttributeError Ltc Hotspot <ltc.hotspot@gmail.com> - 2015-08-12 12:05 -0700
Re: AttributeError Denis McMahon <denismfmcmahon@gmail.com> - 2015-08-12 20:38 +0000
RE: AttributeError "Clayton Kirkwood" <crk@godblessthe.us> - 2015-08-12 14:15 -0700
Re: AttributeError Emile van Sebille <emile@fenx.com> - 2015-08-12 14:32 -0700
Re: AttributeError Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-08-12 22:45 +0100
Re: AttributeError Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-08-12 22:51 +0100
Re: AttributeError Ltc Hotspot <ltc.hotspot@gmail.com> - 2015-08-12 14:04 -0700
Re: AttributeError Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-08-13 10:37 +0100
Re: AttributeError Ben Finney <ben+python@benfinney.id.au> - 2015-08-13 21:08 +1000
Re: AttributeError MRAB <python@mrabarnett.plus.com> - 2015-08-12 21:04 +0100
Re: AttributeError Denis McMahon <denismfmcmahon@gmail.com> - 2015-08-12 21:16 +0000
Re: AttributeError MRAB <python@mrabarnett.plus.com> - 2015-08-12 23:35 +0100
Re: AttributeError Ltc Hotspot <ltc.hotspot@gmail.com> - 2015-08-12 16:05 -0700
Re: AttributeError Emile van Sebille <emile@fenx.com> - 2015-08-12 16:15 -0700
Re: AttributeError MRAB <python@mrabarnett.plus.com> - 2015-08-13 00:16 +0100
Re: AttributeError Ltc Hotspot <ltc.hotspot@gmail.com> - 2015-08-12 16:46 -0700
Re: AttributeError Denis McMahon <denismfmcmahon@gmail.com> - 2015-08-13 09:15 +0000
Re: AttributeError Ltc Hotspot <ltc.hotspot@gmail.com> - 2015-08-13 02:41 -0700
Re: AttributeError Denis McMahon <denismfmcmahon@gmail.com> - 2015-08-13 11:06 +0000
Re: AttributeError MRAB <python@mrabarnett.plus.com> - 2015-08-13 00:56 +0100
Re: AttributeError Denis McMahon <denismfmcmahon@gmail.com> - 2015-08-12 20:28 +0000
Re: AttributeError Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-08-12 21:58 +0100
Re: AttributeError Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-08-12 03:46 +0100
Re: AttributeError Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-08-12 04:32 +0100
Re: AttributeError Chris Angelico <rosuav@gmail.com> - 2015-08-12 13:49 +1000
Re: AttributeError Denis McMahon <denismfmcmahon@gmail.com> - 2015-08-12 11:36 +0000
Re: AttributeError MRAB <python@mrabarnett.plus.com> - 2015-08-12 16:09 +0100
Re: AttributeError Gene Heskett <gheskett@wdtv.com> - 2015-08-12 17:25 -0400
Re: AttributeError Ltc Hotspot <ltc.hotspot@gmail.com> - 2015-08-12 15:02 -0700
Re: AttributeError Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-08-12 23:16 +0100
csiph-web