Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!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.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; '16,': 0.03; 'attribute': 0.07; 'column': 0.07; 'string': 0.09; 'function,': 0.09; 'quotes:': 0.09; 'def': 0.12; '"0"': 0.16; 'subject:String': 0.16; 'subject:object': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'passing': 0.19; 'error': 0.23; 'instead.': 0.24; 'integer': 0.24; 'looks': 0.24; 'skip:" 30': 0.26; 'pass': 0.26; 'skip:" 20': 0.27; 'header :In-Reply-To:1': 0.27; 'skip:p 30': 0.29; 'skip:( 40': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'getting': 0.31; 'quotes': 0.31; 'file': 0.32; '(most': 0.33; 'reader': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'skip:> 10': 0.36; 'should': 0.36; 'list': 0.37; 'skip:o 20': 0.38; 'to:addr:python- list': 0.38; 'pm,': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'called': 0.40; 'subject:"': 0.60; "you're": 0.61; 'first': 0.61; 'receive': 0.70; '2013': 0.98 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 :content-type; bh=xUTitJ9l8IOP3SJvqwvDVVN+0O5zWYumTWVAGcephI4=; b=bLq+M5X1aAXraAGHvuk46Yu3+196yEKecz8zXx2QFbOObng3/eiR9v+iHTlo1ntkrz L7zLkFRgazF/Gq/NN2aHTNjmVZ3+pzUyc84mmv0G4woMoe9RZht7ZaE7PSTDWPN+CL9I Py6u2F5tZ5zTqxZbvkZx+kumEMruBXMJSRgzmiFJ7Txo9TTRXSOqLSbeDPkAUWd3rdfP NHrZ/UTa4NFdLgmFyTI0EBSzgFHbUQFfLtLW9D48+2xnfnO67Fwhk2NPUaey/dQWATPH kuwPHmk5h8p0SOoaiRnilomUYjfTTAUTbHvQ49bHtsKITFqInbLDrZYLZESQmGda3J9A ZqwA== X-Received: by 10.66.144.98 with SMTP id sl2mr35999318pab.92.1369766538876; Tue, 28 May 2013 11:42:18 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <8d8143e8-74f3-43a0-9a52-06b60e857984@googlegroups.com> References: <8d8143e8-74f3-43a0-9a52-06b60e857984@googlegroups.com> From: Ian Kelly Date: Tue, 28 May 2013 12:41:37 -0600 Subject: Re: String object has no attribute "append" To: Python Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 31 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1369766542 news.xs4all.nl 15958 [2001:888:2000:d::a6]:41711 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:46325 On Tue, May 28, 2013 at 12:25 PM, Matt Graves wrote: > I receive this error while toying around with Functions... > > def pulldata(speclist,speccolumn): > with open('profiles.csv', 'r') as f: > reader = csv.reader(f) > for column in reader: > (speclist).append(column[('speccolumn')]) > > pulldata(speclist = 'numbers', speccolumn = "0") > > >>Traceback (most recent call last): >> File "C:\Desktop\Python\CFI\Devices V2\users.py", line 17, in >> pulldata(speclist = 'numbers', speccolumn = "0") >> File "C:\Desktop\Python\CFI\Devices V2\users.py", line 16, in pulldata >> (speclist).append(column[('speccolumn')]) >>AttributeError: 'str' object has no attribute 'append' > > I'm getting the error because it should say "numbers.append", but it is reading it as "(speclist).append". > > This is my first time playing with functions, so be gentle. It looks like you're trying to pass in a list called 'numbers' into the pulldata function, but that is not what's happening. Because of the single quotes you have around numbers, you are passing in the /string/ 'numbers' and calling it 'speclist' instead. The same goes for speccolumn as well; I think you mean to pass in the integer 0, but you're passing in the string "0" instead. Try it without the quotes: pulldata(speclist = numbers, speccolumn = 0)