Newbie OOP question

Christopher Koppler klapotec at chello.at
Tue Nov 18 00:58:12 EST 2003


On Mon, 17 Nov 2003 21:44:55 -0400, "Ed" <avoidspam at nospam.com> wrote:

>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()
>
>
>when I run runDog.py ./runDOG.py it keeps coming up with an AttributeError:
>class Commands has no attribute 'printName"
>
>What am I doing wrong?

Either you're not posting all relevant code, or you didn't actually
try out the code in the form you posted it. If the former, then `a`
seems to be defined in your Commands module, and we can't see that, if
the latter, then you probably meant x.printName(), and we still need
to know about your Commands module to help you. Or else you should've
gotten another error, since `a` hasn't been assigned to or defined as
anything.

>
>thanks!
>Ed
>When
>
>


--
Christopher




More information about the Python-list mailing list