So I'm writing a small program in Python. It's not going to be very demanding and is for fun so doesn't necessarily need to be optimized for speed or resources or any of that and I'm far from pro so if this is a ridiculous question sorry, BUT I am curious:
I am defining several small functions (like 5 lines) that will need libraries to be imported (urllib
, xml.etree
, etc.). Is there a reason to do them outside of the function, like at the beginning of my code, instead of as the first lines of the function? I would think that having it in the function would make it easier to steal those functions effectively in the future but I was also thinking it my slow down things a bit. Is there any hard and fast rule or rule of thumb here? And if not, does anyone have any opinions?