[Tutor] Error when trying to use classes
Alan Gauld
alan.gauld at yahoo.co.uk
Tue Feb 7 14:01:00 EST 2017
On 07/02/17 15:34, Rafael Skovron wrote:
> My general workflow is I edit in vim, then invoke python3 interpreter,
> import the module and try to use the Class and methods from the class.
>
> For example, importing customer.py and assigning this object yields:
>
>>>> rafael = Customer('rafael',100.0)
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> NameError: name 'Customer' is not defined
You didn't show us the import but I'm guessing
you just did
import customer
In that case you need to reference the module:
rafael = customer.Customer(....)
HTH
--
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