[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
Follow my photo-blog on Flickr at:

More information about the Tutor mailing list