[Tutor] classes & required method not working

Alan Gauld alan.gauld at blueyonder.co.uk
Thu Jun 24 03:24:58 EDT 2004


> I have a class problem. I have a script, ggScanStock.py which
defines a
> class ScanData :
>

> 'stub' class methods I have defined these methods in a seperate
script,
> ggpcprofit.py
>
> #!/usr/bin/env python
>
> import os,ggScanStock
>
> class pcprofit(ScanData):

You need to specify where ScanData lives:

class pcprofit(ggScanStock.ScanData):

> However when I try & execute ggpcprofit.py I get :
>
> bash-2.05b$ ./ggpcprofit.py
> Traceback (most recent call last):
>   File "./ggpcprofit.py", line 5, in ?
>     class pcprofit(ScanData):
> NameError: name 'ScanData' is not defined

Its looking for the name ScanData in your module but it can't find
it because its in the ggScanStock module. You only imported the name
ggScanStock not all of its contents.

Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld




More information about the Tutor mailing list