Newbie OOP question
Lawrence Oluyede
raims at dot.com
Tue Nov 18 01:51:50 EST 2003
"Ed" <avoidspam at nospam.com> writes:
> I'm trying to create an OOP script but havn't quite figured out to do it.
> Here's and example of what I'm trying to do.
>
> 1st file. DOG.py
>
> class DOG:
> def printName(self):
> print "DOG"
>
> 2nd file: runDog.py
>
> #!/usr/bin/python
> import sys
> from Commands import *
> x = Commands()
> a.printName()
What is "Commands"?
Where do you have instantiated a?
The right way to use DOG class in DOG.py is:
#!/usr/bin/env python
from DOG import DOG
dg = DOG()
dg.printName()
Nothing more, nothing less :)
> when I run runDog.py ./runDOG.py it keeps coming up with an AttributeError:
> class Commands has no attribute 'printName"
What class/module is Commands?
--
Lawrence "Rhymes" Oluyede
http://loluyede.blogspot.com
More information about the Python-list
mailing list