Re: [Tutor] function error

2010-10-02 Thread ALAN GAULD
> ## > import turtle, random > > def checkForward(distance): > old_position = turtle.position() > turtle._pen.up() > turtle.forward(distance) > forward_failed = outOfBounds() you set forward faile

Re: [Tutor] function error

2010-10-02 Thread roberto
On Sat, Oct 2, 2010 at 7:45 PM, Steve Willoughby wrote: > On 02-Oct-10 10:32, Emile van Sebille wrote: >>> >>> File "my_turtle.py", line 19 >>> if (abs(turtle.position()[0])> turtle.window_height()/2) or >>> ^ >>> SyntaxError: invalid syntax > > How does Python know that the next line is the conti

Re: [Tutor] function error

2010-10-02 Thread Emile van Sebille
On 10/2/2010 10:45 AM Steve Willoughby said... On 02-Oct-10 10:32, Emile van Sebille wrote: Well, not really -- this is the OPs code. I was responding to Joel's comment of not seeing the entire post. File "my_turtle.py", line 19 if (abs(turtle.position()[0]) > turtle.window_height()/2) or

Re: [Tutor] function error

2010-10-02 Thread Steve Willoughby
On 02-Oct-10 10:32, Emile van Sebille wrote: File "my_turtle.py", line 19 if (abs(turtle.position()[0])> turtle.window_height()/2) or ^ SyntaxError: invalid syntax How does Python know that the next line is the continuation of your if statement, instead of the beginning of a new line of code?

Re: [Tutor] function error

2010-10-02 Thread Emile van Sebille
On 10/2/2010 10:16 AM Joel Goldstick said... ## import turtle, random def checkForward(distance): old_position = turtle.position() turtle._pen.up() # no show/hide turtle methods in my turtle modul

Re: [Tutor] function error

2010-10-02 Thread Joel Goldstick
On Sat, Oct 2, 2010 at 12:43 PM, roberto wrote: > On Thu, Sep 30, 2010 at 1:45 PM, ALAN GAULD wrote: >> Copy the code into a text file with a name ending in .py - lets call it >> myfile.py for now >> (if you have not already done so) >> >> From a bash prompt type >> >> $ python myfile.py >> >> Th

Re: [Tutor] function error

2010-10-02 Thread roberto
On Thu, Sep 30, 2010 at 1:45 PM, ALAN GAULD wrote: > Copy the code into a text file with a name ending in .py - lets call it > myfile.py for now > (if you have not already done so) > > From a bash prompt type > > $ python myfile.py > > Then cut n paste any error messages into an email to the list

Re: [Tutor] function error

2010-09-30 Thread ALAN GAULD
ttp://www.alan-g.me.uk/ - Original Message > From: roberto > To: Alan Gauld > Cc: tutor@python.org > Sent: Thursday, 30 September, 2010 10:02:51 > Subject: Re: [Tutor] function error > > On Wed, Sep 29, 2010 at 11:13 PM, Alan Gauld >wrote: > > > >

Re: [Tutor] function error

2010-09-30 Thread roberto
On Wed, Sep 29, 2010 at 11:13 PM, Alan Gauld wrote: > > OK, Thats a non standard error trace so presumably you are running it inside > an IDE of some kind? It may be the IDE is masking the true error. > What happens if you just execute the code from a shell prompt in a console > window?  Can you s

Re: [Tutor] function error

2010-09-29 Thread Alan Gauld
"roberto" wrote Perhaps if you provide the full traceback from the error here it is: TypeError Traceback (most recent call last) ~/randomMove2.py in () > 1 2 3 4 5 ... ~/checkForward.py in out_of_bounds() 19 20 def outOfBo

Re: [Tutor] function error

2010-09-29 Thread Evert Rol
>> Perhaps if you provide the full traceback from the error (assuming you're >> still getting this >error); tracebacks generally show the offending code as >> well. It may be something that's >simply overlooked but shows in the >> traceback. >> >> > > here it is: > > TypeError

Re: [Tutor] function error

2010-09-29 Thread roberto
On Tue, Sep 28, 2010 at 8:26 PM, Evert Rol wrote: > > Perhaps if you provide the full traceback from the error (assuming you're > still getting this >error); tracebacks generally show the offending code as > well. It may be something that's >simply overlooked but shows in the > traceback. > >

Re: [Tutor] function error

2010-09-28 Thread Evert Rol
>> It seems that ur turtle.position doesn't return a list because of this when >> indexing is done on that u get this kind of error. >> --nitin > > it seemed to me that kind of error but then i found that it was a > list, as expected: > > $ type(turtle.position()) > $ > $ abs(turtle.position()[

Re: [Tutor] function error

2010-09-28 Thread roberto
On Tue, Sep 28, 2010 at 12:35 PM, Nitin Das wrote: > It seems that ur turtle.position doesn't return a list because of this when > indexing is done on that u get this kind of error. > --nitin it seemed to me that kind of error but then i found that it was a list, as expected: $ type(turtle.posi

Re: [Tutor] function error

2010-09-28 Thread Nitin Das
It seems that ur turtle.position doesn't return a list because of this when indexing is done on that u get this kind of error. --nitin On Tue, Sep 28, 2010 at 3:39 PM, Alan Gauld wrote: > > "roberto" wrote > > > i have the following error when i call this function: >> 20 def outOfBounds(): >>

Re: [Tutor] function error

2010-09-28 Thread Alan Gauld
"roberto" wrote i have the following error when i call this function: 20 def outOfBounds(): ---> 21 if abs(turtle.position()[0]) > turtle.window_height()/2 or abs(turtle.position()[1]) > turtle.window_width()/2: 22 return "true" 23 else: TypeError: 'f

[Tutor] function error

2010-09-27 Thread roberto
hello, i have the following error when i call this function: 20 def outOfBounds(): ---> 21 if abs(turtle.position()[0]) > turtle.window_height()/2 or abs(turtle.position()[1]) > turtle.window_width()/2: 22 return "true" 23 else: TypeError: 'function' ob