Is this type of forward referencing possible?

Kooks are people too greedware at
Sun Mar 15 08:09:21 CET 2009

If I try this:

class  A:
    someType = B

class B:
    anotherType = A

I get:
<type 'exceptions.NameError'>: name 'B' is not defined
      args = ("name 'B' is not defined",)
      message = "name 'B' is not defined"

Presumably because I'm instantiating an instance of a type object (B)
that doesn't exist yet.

Is there any way to do this?

Why I'd want to do this actually has to do with Google's datastore
api.  I'm doing something similar to this:

from google.appengine.ext import db

class  A:
    aB = db.ReferenceType(B)

class B:
    anA = db.ReferenceType(A)

More information about the Python-list mailing list