On Oct 19, 8:22 am, dmitrey <[EMAIL PROTECTED]> wrote:
> Hi all,
> I have the code like this one:
>
> from myMisc import ooIter
> class MyClass:
>     def __init__(self): pass
>     iterfcn = lambda *args: ooIter(self) # i.e pass the class instance
> to other func named ooIter
>     field2 = val2
>     field3 = val3 # etc
>
> So it yields "global name 'self' is not defined", that is true. How
> could I handle the situation?
>
> Currently I do (and it works, but give me some troubles - I should
> call MyClass.__init__ for each children class, and there are lots of
> those ones)
>
> class MyClass:
>     def __init__(self):
>         iterfcn = lambda *args: ooIter(self) # i.e pass the class
> instance to other func named ooIter
>     field2 = val2
>     field3 = val3 # etc
>
> I suspect it has better solution, is it?
> Thank you in advance, Dmitrey

without having tested - I think this should work for you:

from myMisc import ooIter

class MyClass:
     def __init__(self): pass
     iterfcn = lambda self: ooIter(self)

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to