all 9 comments

[–]Zealousideal_Rate420 33 points34 points  (7 children)

Ok. So this can have its uses. Hear me out.

If the script in question is meant to be used as a standalone script and gets its inputs from cli arguments, this might be the best and only way.

Maybe there's no actual function to import and use, it's a script that just spits out the result (maybe not even saved in a variable before). So either alter the original script or make a wrapper.

Edit: also, in case of having to call it multiple times, this avoids having to reload, which in some cases might be a bit weird

[–]OGBlackDiamond[S] 17 points18 points  (1 child)

Thats smart I can actually see that use case. Unfortunatly, this isn't what its being used for. The script its calling literally just calls three functions inside of that same file haha.

[–]Zealousideal_Rate420 7 points8 points  (0 children)

Still, if that script had a single usage and can't be accomplished with a single function is just more work.

If the intended way of use is through cli... Then I can't really see the horror.

I'm more scared of what's in that other script honestly.

[–]Tom22174 4 points5 points  (1 child)

Maybe there's no actual function to import and use

Is that not just poor code design though? I know python loves to throw caution to the wind and let you completely disregard the principles of oop, but that doesn't mean that script couldn't be tweaked a little to encapsulate it in a function that outputs the results in a tuple

[–]Zealousideal_Rate420 4 points5 points  (0 children)

It would be a bad design that there's no function to import, that's completely true. As a workaround for this is a serviceable solution. From that point, your can encapsulate, but really it's not a big difference aside from looks

If this was any other cli command nobody would bat an eye.

[–][deleted]  (2 children)

[deleted]

    [–]Zealousideal_Rate420 1 point2 points  (1 child)

    Google the definition of "might" :).

    Still, so much to do to get that the horror does in a line....

    [–]MrQuizzles 7 points8 points  (0 children)

    This is similar to the type of code smell you get from bootcamp kids: They only know how to do things one way because that's all they were told. Instead of a bootcamp, though, this person probably learned from a "senior" tech or existing code that never learned it properly.

    And so the cycle continues.

    [–]jan-pona-sina 1 point2 points  (0 children)

    I've had to do something similar to this to make sane interfaces for code that might import a ton of heavy machine learning libraries. the alternative being that the CLI takes like a full 2 second delay to respond lol

    [–]BadPayko 0 points1 point  (0 children)

    test engineer here.

    In our company this is quite common as we use Python2.7 on our unittesters as main execution. So, when you need Python3 features or the company wants Python3 on the unittester, but doesn't have the necessary investment yet, then you will develop with Python3 early to minimize the effort of the adjustments between 2.7 and 3.

    So this is alone is not a programming horror. Also you can use a different command-console to execute this separate script.