Python needs an actual default function
-
I thought confusion about indent levels was the whole point of using python
But it feels like main function should not be indented
-
Since Java 21, this has been shortened significantly. https://www.baeldung.com/java-21-unnamed-class-instance-main
Impossible.
-
Nah
self
is quite important. The main part of a method is to access the state of the object.self
is just the interface to it.Guess I just prefer languages that do it this way:
class AClass { var aProp = 0 fun aMethod() { aProp++ } }
Though I suppose confusion and bugs can happen when you do something like:
class AClass { var aProp = 0 fun aMethod(aProp: Int) { // `this.aProp` is needed to access the property } }
-
Does Lua rank far below python for you? I have so much rage against it. At least with Python I don't have to do a bunch of steps to just get it to do something. May take me a while to get through bad Python code, but Lua makes my eyes bleed and I begin to regret my life choices in trying to understand wtf these people wrote.
Never had the opportunity to work with it. Python is much more pervasive compared to Lua I reckon
-
Also, do y'all call main() in the if block or do you just put the code you want to run in the if block?
wrote on last edited by [email protected]wait till you see
if __name__ = "__main__": main() `
-
wait till you see
if __name__ = "__main__": main() `
wrote on last edited by [email protected]Luckily Python is one step ahead:
Python 3.13.3 (main, Apr 22 2025, 00:00:00) [GCC 15.0.1 20250418 (Red Hat 15.0.1-0)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> if __name__ = "__main__": ... ... main() ... File "<python-input-0>", line 1 if __name__ = "__main__": ^^^^^^^^^^^^^^^^^^^^^ SyntaxError: invalid syntax. Maybe you meant '==' or ':=' instead of '='?
-
Luckily Python is one step ahead:
Python 3.13.3 (main, Apr 22 2025, 00:00:00) [GCC 15.0.1 20250418 (Red Hat 15.0.1-0)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> if __name__ = "__main__": ... ... main() ... File "<python-input-0>", line 1 if __name__ = "__main__": ^^^^^^^^^^^^^^^^^^^^^ SyntaxError: invalid syntax. Maybe you meant '==' or ':=' instead of '='?
wrote on last edited by [email protected]yea I also couldnt get the formatting to work right, triple quotes kept turning things into accented letters, so I gave up.
and also := also known as the walrus operator is very fun and sometimes very convenient to use
-
Someone should get their hands on someone like me and someone like you and study their brains. I spend most time with PHP and C++, and Python looks like an attempt to write code like prose literature. Very interesting how much of this is habbit, as it can't be just that: reading prose and poetry in English/Russian/Japanese never produced this kind of resentment
wrote on last edited by [email protected]I would love that! I do think there are probably interesting underlying personality factors / preferences for a lot of this stuff as well.
I do think that many of Python's characteristics map to my own personality and I bet there's something to that. Things like syntax of course, but not strictly syntax, also things like "The Zen of Python", and the way its a "jack-of-all-trades, master-of-none". I also really kind of need the freedom and accompanying responsibility to break any "rules" on a whim (Python will happily let you overwrite its own internals while running, for instance), but I almost never do anything that uses it...
I could probably keep going lol. Feels like a "people looking like their pets" scenario, lmao
-
I would love that! I do think there are probably interesting underlying personality factors / preferences for a lot of this stuff as well.
I do think that many of Python's characteristics map to my own personality and I bet there's something to that. Things like syntax of course, but not strictly syntax, also things like "The Zen of Python", and the way its a "jack-of-all-trades, master-of-none". I also really kind of need the freedom and accompanying responsibility to break any "rules" on a whim (Python will happily let you overwrite its own internals while running, for instance), but I almost never do anything that uses it...
I could probably keep going lol. Feels like a "people looking like their pets" scenario, lmao
wrote on last edited by [email protected]Thank you for sharing your thoughts
Python will happily let you overwrite its own internals while running, for instance
Damn, that's cool and I did not even know. Pretty sure I would not do this in production code, but very glad very this possibility exists
-
The
if
block is still in the global scope, so writing the code in it is a great way to find yourself scratching your head with a weird bug 30 minutes later.Interesting observation. Can you give an example where this is relevant?