Path: csiph.com!goblin3!goblin1!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed8.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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'skip:[ 20': 0.03; '---------': 0.05; 'mrab': 0.05; 'data:': 0.07; 'val': 0.07; 'wednesday,': 0.07; 'cc:addr:python-list': 0.09; 'email addr:python.org]': 0.09; 'lst': 0.09; 'snippet': 0.09; 'jan': 0.11; 'syntax': 0.13; 'wed,': 0.15; 'message-----': 0.15; 'frame,': 0.16; 'function?': 0.16; 'handle:': 0.16; 'last)': 0.16; 'line.split()': 0.16; 'wrote:': 0.16; 'attribute': 0.18; '>>>': 0.20; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'aug': 0.20; 'to:2**1': 0.21; 'cc:no real name:2**0': 0.22; 'am,': 0.23; 'code,': 0.23; '(most': 0.24; 'header:In-Reply-To:1': 0.24; 'sort': 0.25; "doesn't": 0.26; 'error': 0.27; 'raw': 0.27; 'key,': 0.29; 'code:': 0.29; 'print': 0.30; 'url:mailman': 0.30; 'code': 0.30; 'skip:- 30': 0.32; 'url:python': 0.33; 'sat': 0.33; 'traceback': 0.33; 'open': 0.33; 'skip:- 10': 0.34; 'url:listinfo': 0.34; 'file': 0.34; 'handle': 0.34; 'add': 0.34; 'list': 0.34; 'sent:': 0.35; 'cc:': 0.35; 'fri': 0.35; 'subject:': 0.35; "isn't": 0.35; 'but': 0.36; 'there': 0.36; 'url:org': 0.36; 'email addr:python.org': 0.36; 'keyword': 0.36; 'subject:: ': 0.37; '12,': 0.37; 'wanted': 0.37; 'why': 0.39; 'data': 0.39; 'skip:- 60': 0.39; 'from:': 0.39; 'url:mail': 0.40; 'subject:skip:A 10': 0.63; 'hours': 0.65; 'python-list': 0.66; 'here': 0.66; 'email name:python-list': 0.67; 'url:tinyurl': 0.67; 'header:Reply-To:1': 0.67; 'reply-to:no real name:2**0': 0.71; 'august': 0.75; '--->': 0.84; '9:45': 0.84; 'dict()': 0.84; 'received:68.178.252': 0.84; 'received:68.178': 0.91 Reply-To: From: "Clayton Kirkwood" To: "'Ltc Hotspot'" , "'MRAB'" Cc: References: <0baa3bd5-9f80-4d4e-9367-84e2a32d8c70@googlegroups.com> <55CA92BA.7070905@mrabarnett.plus.com> <103ea014-9bdb-4c37-acd1-cdc64f5f721e@googlegroups.com> <3f132c37-bdb5-4313-9285-69e094392ccf@googlegroups.com> <55CB7823.8010402@mrabarnett.plus.com> In-Reply-To: Subject: RE: AttributeError Date: Wed, 12 Aug 2015 10:31:25 -0700 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 15.0 Thread-Index: AQCUp+mgC+b0JRESS9VHJ0USIr2mKgNfLhqfAtMds3QCgSt+rAG5HC7pAwH9lqYCRXvZ5wGcvbuzAbkhPS+f6KnaIA== Content-Language: en-us 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: 144 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1439400787 news.xs4all.nl 2922 [2001:888:2000:d::a6]:36673 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:95302 > -----Original Message----- > From: Python-list [mailto:python-list- > bounces+crk=3Dgodblessthe.us@python.org] On Behalf Of Ltc Hotspot > Sent: Wednesday, August 12, 2015 9:57 AM > To: MRAB > Cc: python-list@python.org > Subject: Re: AttributeError >=20 > MRAB, >=20 > I ran the code, and the output: >=20 >=20 > Raw data code: > handle =3D """From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 2008 = From > louis@media.berkeley.edu Fri Jan 4 18:10:48 2008 > """.split("\n") > # Snippet file data: mbox-short.txt >=20 > count =3D dict() > #fname =3D raw_input("Enter file name: ")# Add Snippet file #handle = =3D open > (fname, 'r')# Add Snippet file for line in handle: > if line.startswith("From "): > time =3D line.split() # Sort time >=20 > hours =3D list.split(":")[5] # Sort hours > line =3D line.rstrip() >=20 > count[hours] =3D count.get(hours, 0) + 1 # counter >=20 > lst =3D [(val,key) for key,val in count.items()] >=20 > print key, val >=20 > -------------------------------------------------------------------------= --- --------- > Syntax message: > In [45]: %run assignment_10_2_v_06 >=20 > AttributeError > Traceback (most recent call last) > C:\Users\vm\Desktop\apps\docs\Python\week_10\assignment_10_2_v_06. > py in > () > 11 time =3D line.split() # Sort time > 12 > ---> 13 hours =3D list.split(":")[5] # Sort hours > 14 line =3D line.rstrip() > 15 >=20 > AttributeError: type object 'list' has no attribute 'split' >From my na=EFve view what you wanted was not list.split but line.split. = Isn't list a keyword or function? Crk >=20 > In [46]: >=20 > Regards, > Hal >=20 > On Wed, Aug 12, 2015 at 9:45 AM, MRAB > wrote: > > On 2015-08-12 17:29, Ltc Hotspot wrote: > >> > >> Denis, > >> > >> > >> Using the attached file of a diagram as a frame, why is there an > >> attribute message? > >> > > The code in the error report doesn't match the "revised code". > > > >> > >> > >> > >> = --------------------------------------------------------------------- > >> ------------------------------------ > >> Here is the attribute message: > >> AttributeError > >> Traceback (most recent call last) > >> > C:\Users\vm\Desktop\apps\docs\Python\week_10\assignment_10_2_v_06. > py > >> in > >> () > >> 11 time =3D line.split() # Sort time > >> 12 > >> ---> 13 hours =3D list.split(":")[5] # Sort hours > >> 14 line =3D line.rstrip() > >> 15 count[hours] =3D count.get(hours, 0) + 1 > >> > >> AttributeError: type object 'list' has no attribute 'split' > >> > >> In [45]: > >> > >> > >> = --------------------------------------------------------------------- > >> ------------------------------------ > >> Here is the revised code: > >> handle =3D """From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 = 2008 > >>> > >>> From louis@media.berkeley.edu Fri Jan 4 18:10:48 2008 > >> > >> """.split("\n") > >> # Snippet file data: mbox-short.txt > >> > >> count =3D dict() > >> #fname =3D raw_input("Enter file name: ")# Add Snippet file #handle = =3D > >> open (fname, 'r')# Add Snippet file for line in handle: > >> if line.startswith("From "): > >> time =3D line.split() # Sort time > >> > >> hours =3D time.split(":")[5] # Sort hours > >> line =3D line.rstrip() > >> > >> count[hours] =3D count.get(hours, 0) + 1 # counter > >> > >> lst =3D [(val,key) for key,val in count.items()] > >> > >> print key, val > >> > >> > >> > >> URL link, http://tinyurl.com/oyd4ugp > >> > > > > -- > > https://mail.python.org/mailman/listinfo/python-list > -- > https://mail.python.org/mailman/listinfo/python-list