Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #95302

RE: AttributeError

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 <crk@godblessthe.us>
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 <crk@godblessthe.us>
From "Clayton Kirkwood" <crk@godblessthe.us>
To "'Ltc Hotspot'" <ltc.hotspot@gmail.com>, "'MRAB'" <python@mrabarnett.plus.com>
Cc <python-list@python.org>
References <0baa3bd5-9f80-4d4e-9367-84e2a32d8c70@googlegroups.com> <55CA92BA.7070905@mrabarnett.plus.com> <CALa1VB7f1-4Jrp+FCXEY5oCES+epXzMLLNatB_uiiZ2X7=8pPw@mail.gmail.com> <mailman.94.1439341104.3627.python-list@python.org> <103ea014-9bdb-4c37-acd1-cdc64f5f721e@googlegroups.com> <mqfq0t$8np$2@dont-email.me> <3f132c37-bdb5-4313-9285-69e094392ccf@googlegroups.com> <55CB7823.8010402@mrabarnett.plus.com> <CALa1VB52wjJesc8Skp=Uiu9fY-NMvfd8cPVEpnkxdX-22+xO6w@mail.gmail.com>
In-Reply-To <CALa1VB52wjJesc8Skp=Uiu9fY-NMvfd8cPVEpnkxdX-22+xO6w@mail.gmail.com>
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 <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.129.1439400787.3627.python-list@python.org> (permalink)
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

Show key headers only | View raw



> -----Original Message-----
> From: Python-list [mailto:python-list-
> bounces+crk=godblessthe.us@python.org] On Behalf Of Ltc Hotspot
> Sent: Wednesday, August 12, 2015 9:57 AM
> To: MRAB <python@mrabarnett.plus.com>
> Cc: python-list@python.org
> Subject: Re: AttributeError
> 
> 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 <module>
> ()
>      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'

>From my naïve view what you wanted was not list.split but line.split. Isn't
list a keyword or function?
Crk

> 
> In [46]:
> 
> Regards,
> Hal
> 
> On Wed, Aug 12, 2015 at 9:45 AM, MRAB <python@mrabarnett.plus.com>
> 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 <module>
> >> ()
> >>       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
> --
> https://mail.python.org/mailman/listinfo/python-list

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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