[Tutor] Importing classes

Alan Gauld alan.gauld at yahoo.co.uk
Wed Jan 11 14:50:11 EST 2017


On 11/01/17 02:53, kay Cee wrote:
> Is there a proper way to import  a class from a module? If so, please tell.


The most common way is probably:

>>> from mymodule import Myclass
>>>  myobject = Myclass()

but its just as good to do

>>> import mymodule
>>> myobject = mymodule.Myclass()



-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list