help on self._dir
Diez B. Roggisch
deets at nospam.web.de
Mon Jun 9 11:13:53 EDT 2008
Kaushik wrote:
> Hi,
> i'm new to python , and i came across a code like
>
> if ("on_%s" % handler ) in self._dir:
>
> i tried use the a similar method in my class it errors out like
>
> AttributeError: bot instance has no attribute '_dir'
>
> what am i doing wrong?
self._dir is just an attribute that has previously been set somewhere. For
example, like this:
class Foo(object):
def __init__(self):
self._dir = "I'm a fancy value"
So without you providing more code I presume you try to subclass something
and didn't properly set up the base-class - probably missing a call to the
super class' constructor.
Diez
More information about the Python-list
mailing list