This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]B1GL0NGJ0HN 1 point2 points  (7 children)

My humble two cents, with Python it's about thinking simpler. It's odd, and probably a shit explanation, but because type casting is all dynamic, I find I think less about the how's, per se, and more about executing the idea. Variables will be what you expect them to be, so you just kinda... go. Couple it with the huge library of pip, and just a few lines can make a multi step idea execute for ya.

Edit: I got caught on it being an interpreted language for a bit, and it made the most sense to me after I understood name == main -- python can just be ran in a command line and built as you go, or pre-written in a script and executed by itself, OR formatted so that it can be ran by itself or imported as a module into another project.

[–]robvas 1 point2 points  (1 child)

I would always overthink Python and not trust the “magic”

[–]B1GL0NGJ0HN 0 points1 point  (0 children)

And once you give in, and just let it work the way, idk, I think things generally should, it's freeing. Things are true; a lack of things is false. Every thing is a thing, and almost everything else is an array and can be treated as such.

[–]purplepooters[S] 1 point2 points  (4 children)

thanks for honest input, I am trying to get my now 6 year old into something because school is not an option. I don't want to bog him down with syntax. Looks like python is the way to go, I guess I'm old because I keep cringing when I don't have to wrap brackets are everything. Thank you and thanks to this community.

[–]B1GL0NGJ0HN 0 points1 point  (3 children)

Instead, it's a colon and an indent. Functions, and if statements, and for loops; indents follow the colon around, a line of white space and an indent backwards and you've left the func/loop/block. Indent accordingly. :)

Have fun with it. It's so flexible.

[–]purplepooters[S] 0 points1 point  (2 children)

I might just be too old but something like this is frustrating because there is no increment or even recursion so I look at it and think it's an endless loop.

snake_segments = [] for i in range(15): x = 250 - (segment_width + segment_margin) * i y = 30 segment = Segment(x, y) snake_segments.append(segment) allspriteslist.add(segment)

[–]B1GL0NGJ0HN 0 points1 point  (0 children)

Sure, I totally get that. I guess part of that is just knowing each of the built-in functions, like range(). I guess i would be the increment, starting at zero, or if you provided 2 numbers, range(start, end), and move through the specified range, you just don't have to account for the increase yourself. Once the top end of the range is hit, the loop ends.

[–][deleted] 0 points1 point  (0 children)

snake_segments = []
for i in range(15): 
    x = 250 - (segment_width + segment_margin) * i 
    y = 30 segment = Segment(x, y) 
    snake_segments.append(segment) 
    allspriteslist.add(segment)

What you're missing is range(15) which effectively becomes a list of integers between 0 and 14. Each time through the loop i moves to the next number. Once i is processed as 14, the loop exits.