Syntax for importing modules

Hi,
I’m familiar with import NumPy or import matplotlib.
Now, I’m seeing from x import y
e.g:
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap

why does this change? if I type import Basemap from mpl_toolkits.basemap is it any different?

It’s just the syntax you use when you’re importing specific functions or methods from a given library or module. It’s best practice to only import the functions you need (in contrast with the entire module/library) to save on memory usage.

if I type import Basemap from mpl_toolkits.basemap is it any different?’

This will actually throw an error — you’ll need to use the from x import y syntax for it to run correctly.