Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #50886
| Path | csiph.com!aioe.org!news.mixmin.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder3.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <fabiosantosart@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'messages.': 0.05; 'say,': 0.05; 'float': 0.07; 'indices': 0.07; '[0,': 0.09; 'assuming': 0.09; 'item.': 0.09; 'len(x)': 0.09; 'subject:Function': 0.09; 'subject:Number': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'def': 0.12; '2):': 0.16; '[2,': 0.16; 'accepts': 0.16; 'integers,': 0.16; 'range(0,': 0.16; 'returned,': 0.16; 'subject: \n ': 0.16; 'typeerror:': 0.16; 'url:gmane': 0.16; '\xa0you': 0.16; '(0)': 0.16; 'index': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'items.': 0.19; 'pointed': 0.19; 'value.': 0.19; '>>>': 0.22; 'email addr:gmail.com>': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'error': 0.23; '>>>': 0.24; 'errors.': 0.24; 'integer': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; '>': 0.26; 'defined': 0.27; 'values': 0.27; 'header:In- Reply-To:1': 0.27; 'point': 0.28; "doesn't": 0.30; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; '"",': 0.31; 'subject:that': 0.31; 'file': 0.32; 'probably': 0.32; 'run': 0.32; '(most': 0.33; 'skip:& 30': 0.33; 'third': 0.33; 'comment': 0.34; 'message.': 0.35; 'something': 0.35; 'convert': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'accessing': 0.36; 'idle': 0.36; 'right?': 0.36; 'next': 0.36; 'thanks': 0.36; "i'll": 0.36; 'url:org': 0.36; 'list': 0.37; 'implement': 0.38; 'skip:& 10': 0.38; 'list,': 0.38; 'recent': 0.39; 'does': 0.39; 'called': 0.40; 'ian': 0.60; 'first': 0.61; 'to:addr:gmail.com': 0.65; 'sound': 0.68; 'receive': 0.70; 'jul': 0.74; 'links,': 0.74; 'items,': 0.91; '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:date:message-id:subject:from:to :cc:content-type; bh=qXlZPcOB8f212IOuKJITa5L5ZgIzarG126cjA5ciUFY=; b=fJ/yEclODwvrdsgwSxOXtZKOVy2EPfahR1BOm8jRPMzTAgaBsEwNdMiGL083CvaNrf lFEJb98642LF1Vo/Er5n72ZGdJn9uqAPF/2vP2aWLORXzyzsOqpXB1nyvw8SXICpSnMb 6BAS0OKLdeKmU8cj/vAp6j9FJpG/kl7/EvvIoLtKCkK34KNkS7lWlEkYuN36pKY2F7DF 1Ets8IPDpb4+YFMwp3nhJNNASJZTrBx68qO7qscKYHlnLCiP3+D1nsST7z2s/lnEcfbi zSfN5skxcYcZvfLR7eBnUfzw1cVnPNwJMKLuMdxD8/l4zad1leQHAl4G5hbwvd6+HoAS Esjg== |
| MIME-Version | 1.0 |
| X-Received | by 10.49.16.233 with SMTP id j9mr15626714qed.12.1374202103333; Thu, 18 Jul 2013 19:48:23 -0700 (PDT) |
| In-Reply-To | <97eeec63-7a06-47ad-ad8c-863c58369d01@googlegroups.com> |
| References | <8a23cbf1-3cfd-48e3-a460-64551119fde7@googlegroups.com> <mailman.4835.1374138776.3114.python-list@python.org> <537e9d19-6587-4773-8910-df4005505653@googlegroups.com> <mailman.4846.1374185582.3114.python-list@python.org> <f1f2e742-af88-45b8-a585-d1c6cc239e6f@googlegroups.com> <mailman.4849.1374187752.3114.python-list@python.org> <8c5f6217-0029-481f-9bb0-dab1b34180df@googlegroups.com> <mailman.4852.1374191380.3114.python-list@python.org> <2c9344f3-ec42-477f-b9a7-6cf444906298@googlegroups.com> <mailman.4853.1374195892.3114.python-list@python.org> <97eeec63-7a06-47ad-ad8c-863c58369d01@googlegroups.com> |
| Date | Fri, 19 Jul 2013 03:48:23 +0100 |
| Subject | Re: Creating a Program to Decompose a Number and Run a Function on that Decomposition |
| From | Fábio Santos <fabiosantosart@gmail.com> |
| To | CTSB01 <scott.moore270@gmail.com> |
| Content-Type | multipart/alternative; boundary=047d7bea38e2380bca04e1d45c62 |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| 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.4855.1374202112.3114.python-list@python.org> (permalink) |
| Lines | 144 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1374202112 news.xs4all.nl 15901 [2001:888:2000:d::a6]:35157 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:50886 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
On 19 Jul 2013 03:24, "CTSB01" <scott.moore270@gmail.com> wrote:
>
> Thanks for the alternative links, I'll use gmane.org as an access point
next time.
>
> >
> > Don't paraphrase. Just copy/paste it into your email message. And I'm
> >
> > assuming you know to run things from the terminal window, and not from
> >
> > IDLE or something else that messes up the error messages. Your comment
> >
> > about 'orange' doesn't sound promising.
> >
> >
> >
> > As Ian pointed out, you have no return value in this function. You
> >
> > calculate something called 'rtn', but never use it. The last line
> >
> > accomplishes nothing, since rtn is neither assigned nor returned, nor
> >
> > passed nor... You probably wanted:
> >
> >
> >
> > return rtn
> >
>
> Does something like
>
> def phi_m(x, m):
> rtn = []
> for n2 in range(0, len(x) * m - 2):
> n = n2 / m
> r = n2 - n * m
> rtn.append(m * x[n] + r * (x[n + 1] - x[n]))
> print ('n2 =', n2, ': n =', n, ' r =' , r, ' rtn =', rtn)
> return rtn
>
> look right?
>
> It doesn't seem to have any errors. However, I do receive the following
error when trying to implement an x after having defined phi:
>
> >>> x = [0, 1, 1, 2, 3]
> >>> phi_m(x, 2)
> Traceback (most recent call last):
> File "<pyshell#6>", line 1, in <module>
> phi_m(x, 2)
> File "<pyshell#2>", line 6, in phi_m
> rtn.append(m * x[n] + r * (x[n + 1] - x[n]))
> TypeError: list indices must be integers, not float
When you think about it, it makes sense. If you have a list, say,
[2, 5, 1]
You can say, I want the first item (0) or the third item(2) but never, the
one-and-a-halfeth (0.5) item. Python only accepts integer values when
accessing list items.
To access list items, convert your index into an integer value.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Creating a Program to Decompose a Number and Run a Function on that Decomposition CTSB01 <scott.moore270@gmail.com> - 2013-07-17 16:58 -0700
Re: Creating a Program to Decompose a Number and Run a Function on that Decomposition Joshua Landau <joshua@landau.ws> - 2013-07-18 10:12 +0100
Re: Creating a Program to Decompose a Number and Run a Function on that Decomposition CTSB01 <scott.moore270@gmail.com> - 2013-07-18 14:57 -0700
Re: Creating a Program to Decompose a Number and Run a Function on that Decomposition Gary Herron <gherron@digipen.edu> - 2013-07-18 15:12 -0700
Re: Creating a Program to Decompose a Number and Run a Function on that Decomposition CTSB01 <scott.moore270@gmail.com> - 2013-07-18 15:18 -0700
Re: Creating a Program to Decompose a Number and Run a Function on that Decomposition Ian Kelly <ian.g.kelly@gmail.com> - 2013-07-18 16:49 -0600
Re: Creating a Program to Decompose a Number and Run a Function on that Decomposition CTSB01 <scott.moore270@gmail.com> - 2013-07-18 16:04 -0700
Re: Creating a Program to Decompose a Number and Run a Function on that Decomposition Ian Kelly <ian.g.kelly@gmail.com> - 2013-07-18 17:42 -0600
Re: Creating a Program to Decompose a Number and Run a Function on that Decomposition Ian Kelly <ian.g.kelly@gmail.com> - 2013-07-18 17:45 -0600
Re: Creating a Program to Decompose a Number and Run a Function on that Decomposition CTSB01 <scott.moore270@gmail.com> - 2013-07-18 17:25 -0700
Re: Creating a Program to Decompose a Number and Run a Function on that Decomposition "Rhodri James" <rhodri@wildebst.demon.co.uk> - 2013-07-19 00:48 +0100
Re: Creating a Program to Decompose a Number and Run a Function on that Decomposition Dave Angel <davea@davea.name> - 2013-07-18 19:49 -0400
Re: Creating a Program to Decompose a Number and Run a Function on that Decomposition CTSB01 <scott.moore270@gmail.com> - 2013-07-18 17:35 -0700
Re: Creating a Program to Decompose a Number and Run a Function on that Decomposition Dave Angel <davea@davea.name> - 2013-07-18 21:04 -0400
Re: Creating a Program to Decompose a Number and Run a Function on that Decomposition CTSB01 <scott.moore270@gmail.com> - 2013-07-18 19:16 -0700
Re: Creating a Program to Decompose a Number and Run a Function on that Decomposition Dave Angel <davea@davea.name> - 2013-07-18 22:43 -0400
Re: Creating a Program to Decompose a Number and Run a Function on that Decomposition CTSB01 <scott.moore270@gmail.com> - 2013-07-18 19:56 -0700
Re: Creating a Program to Decompose a Number and Run a Function on that Decomposition Fábio Santos <fabiosantosart@gmail.com> - 2013-07-19 03:48 +0100
Re: Creating a Program to Decompose a Number and Run a Function on that Decomposition CTSB01 <scott.moore270@gmail.com> - 2013-07-18 19:54 -0700
csiph-web