r/Python • • Mar 24 '18

A path finder i recently made in Python PyGame

1.5k Upvotes

111 comments sorted by

View all comments

Show parent comments

0

u/[deleted] Mar 25 '18

[deleted]

3

u/King_Joffreys_Tits Mar 25 '18

WHAT THE FUCK that’s amazing!! I’ve been using python for years and never knew that. I initialize a variable to False right above the loop and set it True if I break.

Python seems to have these little amazing nuggets of logic built in, that most of the time go unnoticed. Is there a list of random things like this I could read?

3

u/arachnivore Mar 25 '18

A good place to start is to watch anything with Raymond Hettinger in it.

1

u/preyneyv coder Mar 25 '18

That's pretty cool, but why do you say that a separate finding function is better?

3

u/PinkPandaa Mar 25 '18

the function is reusable. And it reduces the stuff the original function does, which makes it easier to bugfix and to read.