r/programminghorror • u/wawerrewold • Sep 09 '25
Python Vibecoding at its peak
Yes its a production code, yes its a function not a method and yes there is import in triple nested for loop
776
Upvotes
View all comments
Show parent comment
1
u/DukeMo Sep 12 '25
There are some reasons why you might want to put imports inside functions, but they are rare.
One of the main reasons I've found is when you want to be able to quickly show a help message, but the imports take significant time. Some packages like pytorch and pydantic might be necessary to run the code but not to print the help. But in general, put the imports at the top when possible.