By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,813 Members | 1,130 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,813 IT Pros & Developers. It's quick & easy.

help on self._dir

P: n/a
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?

Thanks,
Kaushik
Jun 27 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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
Jun 27 '08 #2

P: n/a
On Jun 9, 8:13*pm, "Diez B. Roggisch" <de...@nospam.web.dewrote:
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
Thanks Diez! that explains a lot :)

Jun 27 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.