On Nov 14, 4:10 pm, "Gabriel Genellina" <[EMAIL PROTECTED]>
wrote:
> En Wed, 14 Nov 2007 04:51:57 -0300, Davy <[EMAIL PROTECTED]> escribió:
>
> > I have write a simple class, I want the function two() to call private
> > function __one(), but there is an error :
> > NameError: global name '_simple__one' is not defined, how to work
> > around it
>
> > class simple:
> >     def __one(self):
> >         print "Hello"
> >     def two(self):
> >         __one()
> >         print "world"
>
> > if __name__ == '__main__':
> >     s = simple()
> >     s.two()
>
> Note that your problem is not related to mangled names: replacing __one by  
> one raises a similar exception.
> Remember that "self" is not implicit: you must use self.__one()
Hi Gabriel,

Thank you. now my code work well )

Davy

>
> "private" methods (and atributes in general) use a single underscore:  
> _one. Double underscores __one are reserved for the (rare) cases when you  
> want to ensure unique names (or name clashes are expected).
>
> --
> Gabriel Genellina


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

Reply via email to