scoping problems

Rich Harkins rharkins at thinkronize.com
Fri Jul 27 15:57:28 EDT 2001


Try this:

class baseclass():
      def __init__(self):
          self.__myfunc__()

class a(baseclass):
	pass

class b(baseclass):
	pass

a.__myfunc__=b
b.__myfunc__=a

__myfunc__ in a and b will reference class instances, not functions, but who
am I to quibble?  :)

Rich


> -----Original Message-----
> From: python-list-admin at python.org
> [mailto:python-list-admin at python.org]On Behalf Of Narayan Desai
> Sent: Friday, July 27, 2001 3:31 PM
> To: python-list at python.org
> Subject: Re: scoping problems
>
>
> I made a mistake when I was describing the problem. Here is the real
> problem; I had mis-formulated the minimal subset needed to cause this
> behavior. The real subset is:
>
> class baseclass():
>       def __init__(self):
>           self.__myfunc__()
>
> class a(baseclass):
>       __myfunc__=b
>
> class b(baseclass):
>       __myfunc__=a
>
> Does anyone know how to get this to work?
>  -nld
>
> >>>>> "Me" == Narayan Desai <desai at mcs.anl.gov> writes:
>
> Me> How can i define the following code: def a():
> Me>     b()
>
> Me> def b():
> Me>     a()
>
> Me> (ignoring for a moment that this would never terminate) How do you
> Me> get the namespaces right?
>
> Me> I would solve this with function prototypes in C, but it isn't
> Me> clear to me how to do this in python.  thanks...
> Me>  -nld
> --
> http://mail.python.org/mailman/listinfo/python-list
>





More information about the Python-list mailing list