[Tutor] what is the basic difference

Dave Angel d at davea.name
Mon Feb 6 20:26:20 CET 2012


On 02/06/2012 02:12 PM, Debashish Saha wrote:
> what is the basic difference between the commands
> import pylab as *
> import matplotlib.pyplot as plt
> import numpy as np
> import numpy as *
import pylab as *    pollutes your global namespace with all kinds of 
symbols.  If you don't know them all, you might accidentally use one of 
them in your own code, and wonder why things aren't working the way you 
expected.

Better is
    import pylab

and then use  pylab.something  to access a symbol from pylab

Some prefer
     import pylab as pab
          (or something)

and then use   pab.something to save some typing.

import matplotlib.pyplot as plt

looks in the matplotlib *package" for the module pyplot, then imports it 
with a shortcut name of plt



-- 

DaveA



More information about the Tutor mailing list