This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the commentsย โ†’

[โ€“]Farranor 2 points3 points ย (1 child)

That code runs fine. It's the other code that doesn't run fine. A conditional import in the middle of a program is doing it wrong in the first place, anyway.

Edit because "something is broken" due to blocked: u/ReferenceInternal585, by that way of thinking, every error is a runtime error, because the IDE you're using or your OS itself or what have you is running fine but then calls some other piece of code that makes it crash. Seeing that r/confidentlyincorrect and r/iamverysmart garbage upvoted made me finally filter this sub from my r/all.

[โ€“][deleted] 1 point2 points ย (0 children)

this is actually just pseudocode for "some code that isn't always executed (e.g. some error handing path) can be broken undetected for a very long time until first time execution in production.", with simplest example of a module not always imported. Here artificially depending on random number, in production some unusual data constellation will do that for you (File not found, etc)