Creating a module that uses itself

Greg Krohn infinitystwin.SPAM at IS.BAD.yahoo.com
Mon Mar 18 01:47:51 EST 2002


"Asheesh Laroia" <pan-news at asheeshenterprises.com> wrote in message
news:2yfl8.113994$nl1.19520473 at typhoon.nyroc.rr.com...
> I'm writing a PageMaker-to-specialized-HTML module (henceforth
> "pm2html").  In the module, I define the classes Article, Headline, and
> Photo, among others.
>
> In the Article class, I want to have a Headline object.  Is this
> possible?  Right now, ActivePython's PythonWin spits a syntax error at me
> because the Headline class is not defined.

You should post your code and the actual error traceback. What you're
describing should work -- at least they way that you've described it.
Could there be a typo in your code?

This works for me:

class Article:
    def __init__(self):
        self.headline = Headline()

class Headline:
    pass

class Photo:
    pass

a = Article()



greg





More information about the Python-list mailing list