Path: csiph.com!eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!bcyclone05.am1.xlned.com!bcyclone05.am1.xlned.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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'mrab': 0.05; 'data:': 0.07; 'val': 0.07; 'cc:addr:python-list': 0.09; 'lst': 0.09; 'snippet': 0.09; 'jan': 0.11; 'syntax': 0.13; 'wed,': 0.15; 'frame,': 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; '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; 'message-id:@mail.gmail.com': 0.27; 'key,': 0.29; 'skip:- 100': 0.29; 'code:': 0.29; 'print': 0.30; 'url:mailman': 0.30; 'code': 0.30; 'url:python': 0.33; 'sat': 0.33; 'traceback': 0.33; 'open': 0.33; 'url:listinfo': 0.34; 'file': 0.34; 'handle': 0.34; 'add': 0.34; 'received:google.com': 0.35; 'fri': 0.35; 'there': 0.36; 'url:org': 0.36; 'subject:: ': 0.37; '12,': 0.37; 'why': 0.39; 'data': 0.39; 'url:mail': 0.40; 'subject:skip:A 10': 0.63; 'hours': 0.65; 'here': 0.66; 'url:tinyurl': 0.67; '--->': 0.84; '9:45': 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:date:message-id:subject:from:to :cc:content-type; bh=ev2zgH8zw4Bc3Zvi+ZO6lJi8JjzJjYaA3qL5rCelIjI=; b=CVLTwNNJuHCYzgpAc01ZKMs/6NS1FaA3h8XVZxOb8YC/UKuyCqYir8fgQQqBGUIbGQ HyHhrJRGz6c1pnIGs9WyAfJMN8NUIFk6+cDtkLrW306NIQw9hZV+QLOM3/K9my+slezv QxhdoiydQgOeQy96dQfTl8EN+cM9nAB5FYSi3bdJHPJAl7T1L7qA+9iGN1P8oJJnroLd XDBBZwGxmGow8RQsupVWfKElrXl8YGL+Tk+Oix5vU1eX13G+nS7kbRvLdZ8HnRmKSQ3e h6bQw/Td3u0mdmmPLqAhhANyWbWMXlut7LsoLzJiuTaKZ4Sg4W1k7kmdxAwN85vzld9X O8ww== MIME-Version: 1.0 X-Received: by 10.152.29.6 with SMTP id f6mr32021081lah.85.1439398620775; Wed, 12 Aug 2015 09:57:00 -0700 (PDT) In-Reply-To: <55CB7823.8010402@mrabarnett.plus.com> 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> Date: Wed, 12 Aug 2015 09:57:00 -0700 Subject: Re: AttributeError From: Ltc Hotspot To: MRAB Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 112 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1439398622 news.xs4all.nl 2959 [2001:888:2000:d::a6]:49254 X-Complaints-To: abuse@xs4all.nl X-Received-Bytes: 6761 X-Received-Body-CRC: 1664316417 Xref: csiph.com comp.lang.python:95298 MRAB, I ran the code, and the output: Raw data code: handle = """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 = dict() #fname = raw_input("Enter file name: ")# Add Snippet file #handle = open (fname, 'r')# Add Snippet file for line in handle: if line.startswith("From "): time = line.split() # Sort time hours = list.split(":")[5] # Sort hours line = line.rstrip() count[hours] = count.get(hours, 0) + 1 # counter lst = [(val,key) for key,val in count.items()] print key, val ------------------------------------------------------------------------------------- Syntax message: In [45]: %run assignment_10_2_v_06 AttributeError Traceback (most recent call last) C:\Users\vm\Desktop\apps\docs\Python\week_10\assignment_10_2_v_06.py in () 11 time = line.split() # Sort time 12 ---> 13 hours = list.split(":")[5] # Sort hours 14 line = line.rstrip() 15 AttributeError: type object 'list' has no attribute 'split' In [46]: Regards, Hal 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 = line.split() # Sort time >> 12 >> ---> 13 hours = list.split(":")[5] # Sort hours >> 14 line = line.rstrip() >> 15 count[hours] = count.get(hours, 0) + 1 >> >> AttributeError: type object 'list' has no attribute 'split' >> >> In [45]: >> >> >> --------------------------------------------------------------------------------------------------------- >> Here is the revised code: >> handle = """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 = dict() >> #fname = raw_input("Enter file name: ")# Add Snippet file >> #handle = open (fname, 'r')# Add Snippet file >> for line in handle: >> if line.startswith("From "): >> time = line.split() # Sort time >> >> hours = time.split(":")[5] # Sort hours >> line = line.rstrip() >> >> count[hours] = count.get(hours, 0) + 1 # counter >> >> lst = [(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