Poll: Python "No-nos"

Python has a couple of “no-nos”, which are generally bad practices and shouldn’t be used. What do you think, are people overreacting?

from module import * (Wild Card Import)
  • Go right ahead!
  • Try to avoid, but OK in some scenarios
  • Avoid at all costs!

0 voters

open() outside of with statement
  • Go right ahead!
  • Try to avoid, but OK in some scenarios
  • Avoid at all costs!

0 voters

eval(input())
  • Go right ahead!
  • Try to avoid, but OK in some scenarios
  • Avoid at all costs!

0 voters

Calling Subprocess/os.system() commands
  • Go right ahead!
  • Try to avoid, but OK in some scenarios
  • Avoid at all costs!

0 voters

I might add some more polls later, that’s all I can think of for right now. If you have some suggestions please reply!

3 Likes

In Python it’s exec, not eval.

1 Like

Well actually, eval() isn’t extremely harmful on its own, and the only reason people would use eval(input()) would be to calculate something. Only if the user where to add exec() as input, they could override variables and stuff, but at least IMO its perfectly safe to use exec() as long as you’re not providing it with user input.

3 Likes

What does open( ) without with statement mean?

basically
with <insert your other code here…?>
you dont need to close if you put with open whatever whatever.
so u dont need to do smth like
f.close()

1 Like