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


Groups > comp.lang.python > #46493

Re: User Input

Date 2013-05-30 09:37 -0400
From Dave Angel <davea@davea.name>
Subject Re: User Input
References <e3fd9fdd-efa0-45b8-97b9-b77519012640@googlegroups.com> <2eaa39b8-9e87-402a-b0c0-8c8c5d42fed7@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.2422.1369921090.3114.python-list@python.org> (permalink)

Show all headers | View raw


On 05/30/2013 09:10 AM, Eternaltheft wrote:
> yeah i found out why it wasn't defined before because i tried to put it into a function.

That's not a sentence, and it doesn't make sense in any permutation I 
can do on it.

>
> this is my drawBoard function:
>
> import turtle as Turtle
> Turtle.title("Checkers")
> b = 75
>
> def drawBoard(b):
>
>      Turtle.speed(0)
>
>      Turtle.up()
>
>      Turtle.goto(-4 * b, 4 * b)
>      Turtle.down()
>
>      for i in range (8):
>          Turtle.forward(b)
>          Turtle.right(90)
>          Turtle.forward(b)
>          Turtle.right(90)
>          Turtle.forward(b)
>          Turtle.right(90)
>          Turtle.forward(b)
>          Turtle.right(90)
>          Turtle.forward(b)
>
>      for i in range (1):
>          Turtle.right(90)
>          Turtle.forward(b*2)
>          Turtle.right(90)
>
>      for i in range(8):
>          Turtle.forward(b)
>          Turtle.right(90)
>          Turtle.forward(b)
>          Turtle.right(90)
>          Turtle.forward(b)
>          Turtle.right(90)
>          Turtle.forward(b)
>          Turtle.right(90)
>          Turtle.forward(b)
>
>      for i in range(1):
>          Turtle.left(90)
>          Turtle.forward(b)
>          Turtle.left(90)
>
>      for i in range (8):
>          Turtle.forward(b)
>          Turtle.left(90)
>          Turtle.forward(b)
>          Turtle.left(90)
>          Turtle.forward(b)
>          Turtle.left(90)
>          Turtle.forward(b)
>          Turtle.left(90)
>          Turtle.forward(b)
>
>      for i in range (1):
>          Turtle.right(90)
>          Turtle.forward(b)
>          Turtle.right(90)
>
>      for i in range(8):
>          Turtle.forward(b)
>          Turtle.right(90)
>          Turtle.forward(b)
>          Turtle.right(90)
>          Turtle.forward(b)
>          Turtle.right(90)
>          Turtle.forward(b)
>          Turtle.right(90)
>          Turtle.forward(b)
>
>      for i in range(1):
>          Turtle.left(90)
>          Turtle.forward(b)
>          Turtle.left(90)
>
>      for i in range (8):
>          Turtle.forward(b)
>          Turtle.left(90)
>          Turtle.forward(b)
>          Turtle.left(90)
>          Turtle.forward(b)
>          Turtle.left(90)
>          Turtle.forward(b)
>          Turtle.left(90)
>          Turtle.forward(b)
>
>      for i in range (1):
>          Turtle.right(90)
>          Turtle.forward(b)
>          Turtle.right(90)
>
>      for i in range(8):
>          Turtle.forward(b)
>          Turtle.right(90)
>          Turtle.forward(b)
>          Turtle.right(90)
>          Turtle.forward(b)
>          Turtle.right(90)
>          Turtle.forward(b)
>          Turtle.right(90)
>          Turtle.forward(b)
>
>      for i in range(1):
>          Turtle.left(90)
>          Turtle.forward(b)
>          Turtle.left(90)
>
>      for i in range (8):
>          Turtle.forward(b)
>          Turtle.left(90)
>          Turtle.forward(b)
>          Turtle.left(90)
>          Turtle.forward(b)
>          Turtle.left(90)
>          Turtle.forward(b)
>          Turtle.left(90)
>          Turtle.forward(b)
>
>      for i in range (1):
>          Turtle.right(90)
>          Turtle.forward(b)
>          Turtle.right(90)
>
>      for i in range(8):
>          Turtle.forward(b)
>          Turtle.right(90)
>          Turtle.forward(b)
>          Turtle.right(90)
>          Turtle.forward(b)
>          Turtle.right(90)
>          Turtle.forward(b)
>          Turtle.right(90)
>          Turtle.forward(b)
>
>
> drawBoard(b)
>
> Turtle.done()
>
> it draws an 8x8 board table.
>
> what i initially wanted to do was to return this function if nothing was inputted from the user. i hope that makes more sense :S
>

It makes sense if you're also returning a function object when the user 
does have something to say.  But I can't see how you might be doing 
that, unless you're using a lambda to make up a custom function object.

And you still don't show us the function that contains this input 
statement.  Nor how it gets used.  Is the user supposed to supply a 
value for b, and you put it in a variable called filename ?

And perhaps you meant for your function to CALL drawBoard(), rather than 
returning the function object drawBoard.

-- 
DaveA

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


Thread

User Input Eternaltheft <eternaltheft@gmail.com> - 2013-05-30 04:33 -0700
  Re: User Input Fábio Santos <fabiosantosart@gmail.com> - 2013-05-30 12:45 +0100
  Re: User Input Eternaltheft <eternaltheft@gmail.com> - 2013-05-30 04:48 -0700
    Re: User Input Chris Angelico <rosuav@gmail.com> - 2013-05-30 22:06 +1000
    Re: User Input MRAB <python@mrabarnett.plus.com> - 2013-05-30 13:08 +0100
    Re: User Input Fábio Santos <fabiosantosart@gmail.com> - 2013-05-30 13:10 +0100
  Re: User Input Eternaltheft <eternaltheft@gmail.com> - 2013-05-30 05:19 -0700
    Re: User Input Fábio Santos <fabiosantosart@gmail.com> - 2013-05-30 13:27 +0100
    Re: User Input Chris Angelico <rosuav@gmail.com> - 2013-05-30 22:28 +1000
  Re: User Input Eternaltheft <eternaltheft@gmail.com> - 2013-05-30 05:37 -0700
    Re: User Input Dave Angel <davea@davea.name> - 2013-05-30 08:58 -0400
    Re: User Input Chris Angelico <rosuav@gmail.com> - 2013-05-30 22:59 +1000
  Re: User Input Eternaltheft <eternaltheft@gmail.com> - 2013-05-30 06:10 -0700
    Re: User Input Dave Angel <davea@davea.name> - 2013-05-30 09:37 -0400
      Re: User Input Eternaltheft <eternaltheft@gmail.com> - 2013-05-30 07:03 -0700
        Re: User Input Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-05-30 15:30 +0100
          Re: User Input Eternaltheft <eternaltheft@gmail.com> - 2013-05-30 07:49 -0700
      Re: User Input Eternaltheft <eternaltheft@gmail.com> - 2013-05-30 07:47 -0700
        Re: User Input Joshua Landau <joshua.landau.ws@gmail.com> - 2013-05-30 16:09 +0100

csiph-web