takluyver / mobilechelonian

Turtles on a notebook
Other
100 stars 37 forks source link

A touch more PEP8 #1

Closed andybak closed 9 years ago

andybak commented 9 years ago

I'd like to fix the 'multiple statements on a single line' at line 20 also but that seems like a deliberate choice?

takluyver commented 9 years ago

Thanks!

I don't want to make the example too long and narrow, but if you want to move the penup and pendown calls to separate lines, just leaving left, forward, right together, that would be fine.

andybak commented 9 years ago

I'm not sure a few extra lines in length matter hugely. If the normal Pythonic way of writing the code looks a bit verbose then maybe the API itself is at fault? Could it support chaining like thus:

t.penup().left(90).forward(200).right(90).pendown()

In any case - people have such wonders as mouse wheels and touchpads nowadays and I reckon they can bear the strain of scrolling the page by 6 more lines. In return they get idiomatic Python.

takluyver commented 9 years ago

I'm not designing this API, it's supposed to replicate the API of the stdlib turtle module. Besides, turtle is intended as an educational tool for new programmers, so I don't think muddying the waters with method chaining is a good idea.

PEP 8 is a set of guidelines, not rules. I deviate from them when I think it makes sense to do so.