Skip to main content
10 events
when toggle format what by license comment
Mar 11, 2022 at 11:12 history bounty ended Greedo
Mar 6, 2022 at 20:47 comment added Alex Waygood I agree the edge case is unlikely to come up, but what's so disagreeable about raise SystemExit? That's all that sys.exit() does under the hood, and explicit is better than implicit, after all ;)
Mar 6, 2022 at 15:28 comment added Reinderien Edited for all topics
Mar 6, 2022 at 15:28 history edited Reinderien CC BY-SA 4.0
added 3093 characters in body
Mar 6, 2022 at 15:23 history edited Reinderien CC BY-SA 4.0
added 3093 characters in body
Mar 6, 2022 at 9:20 comment added Greedo Final question if that's okay; I still don't quite get the motivation behind avoiding assert. As mentioned on the other answer, I try to use it only in places where it is "unreachable"/ impossible and hitting it implies a programming error not a runtime/user input/ validation error - removing it should have no effect on the user. If it's reserved for programming errors then, it's not a problem if a user optimises it out, so long as I leave it in for development and tests. Otherwise when is an appropriate use of assert, just unit tests assert expected == actual?
Mar 6, 2022 at 9:13 comment added Greedo ... The import on separate lines I do because it reduced the size of the git diff when you add or remove modules - you can see more easily those changes than if an element of a tuple is removed since that shifts everything along. raise SystemExit is done because apparently if you run python with the -S flag or if site modules are not present, exit won't exist without explicit import whereas raise SystemExit should always work - explanation on YouTube here youtu.be/ZbeSPc5wL0g?t=86
Mar 6, 2022 at 9:03 comment added Greedo +1 for sure, very succinct yet thorough review. I'm flattered you think I've moved past the beginner stage (or maybe you mean "you can't hide behind that label anymore!"), I certainly feel like a beginner writing with a very script-oriented style. The point in try...pass I really agree with, it came from LBYL/EAFP I've been told python is the latter but empty except feels like a bad pattern. I hadn't even considered passing a flag for distinguishing package types - do you envisage one flag for every package, or only one flag for each kind and an array of packages on the command line (collect)
Mar 6, 2022 at 3:19 history edited Reinderien CC BY-SA 4.0
deleted 16 characters in body
Mar 5, 2022 at 21:10 history answered Reinderien CC BY-SA 4.0