Reputation: 5460
There are multiple modules I use on a daily basis, and importing all of them every time I want to use them is quite bothersome.
I was hoping for something such as this
#essentials.py
from bs4 import BeautifulSoup
import requests
etc etc
Then in something else, I could do:
import essentials
r = requests.get(example) #Requests is not defined here, as I have not imported it
soup = BeautifulSoup(r, 'lxml')
Upvotes: 1
Views: 2502
Reputation: 5935
from essentials import *
This will put all the names in essentials.py
into the namespace of the module, if this is done in the top-level of the module.
So you can do
from essentials import *
r = requests.get(example)
soup = BeautifulSoup(r, 'lxml')
Take a look at the official documentation for reference.
Upvotes: 7