Hacker News new | ask | show | jobs
by JdeH 3781 days ago
My coding style took shape long before PEP8 or even Python emerged. I tried following PEP8 for a few months, but since I mosty use C++ and Python in combination, pure PEP8 didn't work on the C++ side of things. So I stick with a kind of geometric mean of my Fortran, Basic, Cobol, Algol, Ada, Pascal, Modula2, C, C++, Python, JavaScript, asssembler and PLC AWL coding styles. But that's just the way Transcrypt itself is coded. Feel free to follow PEP8 completely in your code using Transcrypt. It's parsed by the CPython parser, so no problem there. However, if you use JS libs they won't follow PEP 8 either. And that's probably something to accept, as, however big the Python world, one cannot ignore the JS world when programming for the browser. By the way of all those languages I like Python best. But since I write technical (signal processing) apps, C++ interoperation is an inevitable fact for me. To be more exact about the braces: I started out numerical programming in Fortran66, and wanted a formula to look like this: (a + b) * (c + d), so with blanks surrounding the braces, rather than (a+b)*(c+d) which I found harder to decipher at that time. I stuck with that ever since, for any braces, unless adjacent to each other.
2 comments

Thanks for the response, man! To be completely honest, I definitely don't follow PEP8 100% (especially in regards to continuing-line indentation) because to do so would make some lines quite nasty looking simply for compliance to guidelines (also, I've seen many many projects ignore those rules too). But I don't recall ever seeing any libraries break that specific spacing rule which as some others have pointed out, make the documentation look a bit.. unexpected.

In regards to: > if you use JS libs they won't follow PEP 8 either. > And that's probably something to accept, as, however > big the Python world, one cannot ignore the JS world.

I totally agree. I spend about half of my time writing JS and half in Python and I definitely don't try to enforce PEP8 guidelines onto JS code, simply because it's a Python style guide, not a JS guide. I would try to follow a largely accepted code style of the JS community if I was made aware of one, but there only seems to be a large collection of non-official guides, so just I try to adjust my code style to what seems to be common among all of the "nice"/readable code around the web, or, if I'm working in a large existing code base, the style that is followed in that codebase, unless there's reason good not to.

I guess my general approach is that I prefer to style the code I write based upon the language (sometimes, for example, this requires placing open braces in different positions), and I find this actually helps my mind to switch between languages as they have their own look-and-feel to them.

Thanks for reading, and thanks for writing a very interesting library!

FWIW I prefer the same kind of spacing. So there's at least two of us.
Nice to know!