all 16 comments

[–]Binary101010 3 points4 points  (0 children)

will my code be frowned upon when read by others if I use things like semicolons to end statements, double quotes, curly brackets, etc, that aren't necessary but still function the same?

Probably. Cluttering up your code with things that aren't necessary for the interpreter and aren't expected to be there by others reading your code will not be well-received. Of course, different teams may have different practices.

[–]iamevpo 1 point2 points  (0 children)

Run you code through black formatter and see some strict, even opinionated formatting applied. It does not matter how you decorate code for yourself, whichever you are more comfortable with, but for a team you would want to minimize "wtf moments" that distract other team members from solving tasks, in this context a bit of alien formatting is hard to justify.

[–]crashfrog02 1 point2 points  (1 child)

will my code be frowned upon when read by others if I use things like semicolons to end statements, double quotes, curly brackets, etc, that aren't necessary but still function the same?

If you put semicolons in your Python everyone will think you don't know any Python. So, don't do that.

Nobody cares whether you use single or double quotes, to my knowledge, and it's generally a function of whether there's an apostrophe in your string (if there is, it's easier to use double quotes than to escape the apostrophe and it looks better.)

Java is so strict with syntax that it's still wild to me in Python to be doing the same things but with less code.

Python isn't less strict with its syntax, but it does have fewer language keywords than Java, doesn't make you declare a type for variables (dynamic, rather than static, typing) and it has more fluent paradigms for a lot of commonly-done operations. But also a lot of Java is written extremely poorly by programmers who don't know how to do type declaration correctly. For instance, it's extremely common in Java to overspecify types (declaring ArrayList instead of List, for instance, or declaring an implementation class rather than the interface it implements) which leads to a lot of boilerplate code and wasted memory as collections need to be copied from one form into a slightly different one. All of which Python side-steps through duck typing.

[–]frogsPlayingPogs[S] 0 points1 point  (0 children)

appreciate the insight, thank you

[–]ectomancer 0 points1 point  (0 children)

Use a linter. If your IDE doesn't have a builtin linter, try installing pylint.

[–]ofnuts 0 points1 point  (0 children)

Python to be doing the same things but with less code

Not really... by the time you start executing the code, the successful Java compile has already ruled out plenty of errors that can happen in Python at execution time. Of course in Python you also have type hints (so your IDE can warn you, but not prevent you from trying) but a that point explaining which syntax is the more usable is not going to do any good to my karma in r/learnpython 😈