d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Little Python Help
Add Reply New Topic New Poll
Member
Posts: 19,197
Joined: Nov 13 2008
Gold: 4,787.14
Oct 25 2012 06:30pm
can some1 tell me how this function works? Not sure what to give it as an input (like I kno its a list but not sure how that list is formatted)

Quote
def putBlock(block):

    if (type(block)!=list):
          print ("Error: Not a list")
          return
    else:
          print ("List Detected")
   
   
    label=block[0]
    p=[]
    for coord in block[1:]:
          p.append(coord)

    color=fetchColor(label)

    turtle.begin_fill()
    turtle.fillcolor(color)
    turtle.penup()
   
    k=p[0]
   
   
   
    turtle.setpos(k[0],k[1])
    turtle.pendown()
    for i in range(0,len(p)):
          k=p[i]
         
          if (type(k)!=tuple):
              print ("Error: Not a Tuple")
              return
          else:
              print ("Tuple Detected") 
             
          turtle.setpos(k[0],k[1])
    k=p[0]         
    turtle.setpos(k[0],k[1])       
   
   
    turtle.end_fill()
    turtle.penup()

    return
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Oct 25 2012 07:24pm
Looks like a list of coordinates for turtle graphics.
Member
Posts: 11,637
Joined: Feb 2 2004
Gold: 434.84
Oct 25 2012 07:59pm
Quote (carteblanche @ Oct 25 2012 08:24pm)
Looks like a list of coordinates for turtle graphics.


This, but without the calling method or some other code it's hard to tell.
Member
Posts: 19,197
Joined: Nov 13 2008
Gold: 4,787.14
Oct 25 2012 09:32pm
Quote (carteblanche @ Oct 25 2012 07:24pm)
Looks like a list of coordinates for turtle graphics.


Quote (rockonkenshin @ Oct 25 2012 07:59pm)
This, but without the calling method or some other code it's hard to tell.


there is more code to that (like 12 or so different functions that call upon each other), I didn't wanna post it all because I wanna kinda half figure it out on my own, if I can understand this function to get it running on one instance I can solve the whole problem, but if you guys wanna see the rest of it for better understanding, lmk.
Member
Posts: 4,541
Joined: Sep 15 2011
Gold: 10,391.00
Oct 25 2012 09:35pm
the input it seems to expect is that the first element of the list is a list of properties, while the remainder of the list is just a bunch of coordinates
Member
Posts: 19,197
Joined: Nov 13 2008
Gold: 4,787.14
Oct 25 2012 11:08pm
thank you guys I figured it out :D it was so hard and then so simple -.-
Member
Posts: 11,637
Joined: Feb 2 2004
Gold: 434.84
Oct 26 2012 06:50am
Quote (Shamx @ Oct 26 2012 12:08am)
thank you guys I figured it out :D  it was so hard and then so simple -.-


Welcome to programming ;)

Quote (irimi @ Oct 25 2012 10:35pm)
the input it seems to expect is that the first element of the list is a list of properties, while the remainder of the list is just a bunch of coordinates


I noticed that after I posted. Seems like really bad design and the list should probably be broken out into a better data structure.
Member
Posts: 19,197
Joined: Nov 13 2008
Gold: 4,787.14
Oct 26 2012 08:59am
Quote (rockonkenshin @ Oct 26 2012 06:50am)
Welcome to programming ;)



I noticed that after I posted. Seems like really bad design and the list should probably be broken out into a better data structure.


Ya once I figured out how the list was supposed to look like, formatting the data in the text file to make the functions work wasn't too hard.
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll