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


Groups > comp.lang.python > #6949

Re: Newby Python help needed with functions

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <bahamutzero8825@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.062
X-Spam-Evidence '*H*': 0.88; '*S*': 0.00; 'parameter': 0.05; 'subject:Python': 0.06; 'python': 0.08; 'def': 0.12; 'error:': 0.12; 'am,': 0.14; 'wrote:': 0.14; 'called,': 0.16; 'function)': 0.16; 'keyerror:': 0.16; 'subject:help': 0.20; 'header:In-Reply- To:1': 0.21; "doesn't": 0.25; 'function': 0.25; 'changed': 0.25; 'string': 0.26; 'object': 0.26; 'tried': 0.27; 'instead': 0.29; "won't": 0.30; 'entry': 0.31; "skip:' 10": 0.32; 'to:addr:python- list': 0.33; 'points': 0.34; 'there': 0.35; 'header:User-Agent:1': 0.35; 'skip:" 10': 0.35; 'skip:{ 10': 0.35; 'message- id:@gmail.com': 0.36; 'received:google.com': 0.37; 'received:209.85': 0.37; 'instead.': 0.37; 'but': 0.38; 'subject:: ': 0.38; 'received:192': 0.38; 'should': 0.39; 'received:209': 0.39; 'subject:with': 0.39; 'to:addr:python.org': 0.39; 'received:192.168.1': 0.40; 'your': 0.60; 'below': 0.61; 'here': 0.66; 'accepts': 0.68; 'anything.': 0.72; 'anything,': 0.73; '(s):': 0.84; '09:42': 0.84; 'correctly?': 0.84; 'received:209.85.218.46': 0.91; 'received:mail- yi0-f46.google.com': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:x-enigmail-version:content-type :content-transfer-encoding; bh=svchdo9hP0hETgMzIqrwiBPRd/WYcomBgrpE39qb3P0=; b=GK5Pr66NFEfmJsj8MxDvZED/ScuoA3xiKtOWyRwRCW0N3VDJ34ZhwGC7dZitZRrFrQ T3FgA44bAVDjJxW6NJZpZnykkpeRA64ieYlfT+d00xbtG7PuQV2b/xOAKwYynvxkTL2s 3xS/RF2uSaOWWQqzBf5Kj7Pda2spNLa+GAcb0=
DomainKey-Signature a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:x-enigmail-version:content-type :content-transfer-encoding; b=Jr9lWkZk64Cj2pq1gwJSTcMcz7yeVy3vjrYjrfyy0j3QKFm/vRdhxB7sKr5Vf3DEtT xGDuzaYY+rzE6ffVuVEXt+jpXI5Fb5n1wiBpaU7ThAR+0/KgfwqRC8bSdXpePyfzld7W ozr0AAP4HTSblBECIGs6Z/lMLsyJ4cRI+admI=
Date Fri, 03 Jun 2011 10:10:49 -0500
From Andrew Berg <bahamutzero8825@gmail.com>
User-Agent Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 ThunderBrowse/3.3.5
MIME-Version 1.0
To python-list@python.org
Subject Re: Newby Python help needed with functions
References <BANLkTinpQGQ0wtdkLuVegy_SmyvurQs-yg@mail.gmail.com>
In-Reply-To <BANLkTinpQGQ0wtdkLuVegy_SmyvurQs-yg@mail.gmail.com>
X-Enigmail-Version 1.1.1
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2431.1307113857.9059.python-list@python.org> (permalink)
Lines 27
NNTP-Posting-Host 82.94.164.166
X-Trace 1307113858 news.xs4all.nl 49174 [::ffff:82.94.164.166]:33853
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:6949

Show key headers only | View raw


On 2011.06.03 09:42 AM, Cathy James wrote:
> I need a jolt here with my python excercise, please somebody!! How can
> I make my functions work correctly? I tried below but I get the
> following error:
>
> if f_dict[capitalize]:
>
> KeyError: <function capitalize at 0x00AE12B8>
>
...
>
>  def capitalize (s):
>     """capitalize accepts a string parameter and applies the
> capitalize() method"""
>     s.capitalize()
>
...
>
>     f_dict = {'capitalize': 'capitalize(s)',
>
Your capitalize() function doesn't return anything, therefore
f_dict[capitalize] won't contain anything. Your string s will still be
changed (inside the function) when the function is called, but there is
still no value associated with capitalize().
Also, capitalize in f_dict[capitalize] points to the capitalize function
object instead of the entry in the dictionary. You should call
f_dict['capitalize'] instead.

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


Thread

Re: Newby Python help needed with functions Andrew Berg <bahamutzero8825@gmail.com> - 2011-06-03 10:10 -0500

csiph-web