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


Groups > comp.lang.python > #50883

Re: Creating a Program to Decompose a Number and Run a Function on that Decomposition

From Dave Angel <davea@davea.name>
Subject Re: Creating a Program to Decompose a Number and Run a Function on that Decomposition
Date 2013-07-18 21:04 -0400
References (4 earlier) <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>
Newsgroups comp.lang.python
Message-ID <mailman.4853.1374195892.3114.python-list@python.org> (permalink)

Show all headers | View raw


On 07/18/2013 08:35 PM, CTSB01 wrote:
>   > It's only obvious if you're using Python 3.x.  You have forgotten the
>>
>> parentheses in the call to the print() function.
>>
>>
>> On the other hand, if this is Python 2.x, I have no idea.  Next time,
>>
>> please paste the actual error, not paraphrased.  The error message
>>
>> includes a traceback. and a pointer to where in the line the error was
>>
>> detected.  If it's pointing at the end of the second token, you must be
>>
>> running Python 3.x
>> And since you're using that annoying googlegroups, see this:
>>
>> http://wiki.python.org/moin/GoogleGroupsPython
>>
>>
>> --
>>
>> DaveA
>
> Hi Dave,
>
> There aren't any emails in the Cc slot so I imagine that part is fine, I will definitely edit the extra quotes though I made the mistake of thinking it was just google being google.

Exactly.  And remember, the list is comp.lang.python, while googlegroups 
has tried to pre-empt it by bridging.  Most of us get to it either 
through the nntp server at gmane.org or via email subscription at 
python-list-request@python.org


>  For reference , I'm running Python 3.x.
 >  I'll try out putting the quotes around it.

Parentheses, not quotes.  print() is a function in 3.x

>   The full code is:
>
>>>> 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
>        rtn
>
> SyntaxError: invalid syntax
>
> where the second apostrophe in 'n2 =' is marked in orange.  Thanks to everyone who's helped out so far, hopefully with some experience I'll be able sort out any syntax issues that come my way.
>
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





-- 
DaveA

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


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