] > Re: [Python-projects] Not enough public methods (Logilab.org)

Email Re: [Python-projects] Not enough public methods

from
Mateusz Łoskot <mateusz at loskot dot net>
subject
Re: [Python-projects] Not enough public methods
date
2006/01/16 21:07
Fabien Schwob wrote:

> Another way to be a little more pythonic is to add method to the class. 
> For example, why not adding a method to change the name variable with 
> some logic in it. I would see something like :

> class TestClass:
>     """This is class documentation."""

>     def __init__(self):
>         """Default constructor."""
>         self.id = 0
>         self.name = ""
>         self.params = []

>     def setName(self, name):
>         """A method to change the name with some logic in it."""
>         if name is not "":
>             self.name = name
>     else:
>         raise Error("The name must not be null")


Yup. I think I'll stick to this solution, thanks.
Cheers
-- 
Mateusz Åoskot
http://mateusz.loskot.net
_______________________________________________
Python-Projects mailing list
Python-Projects@lists.logilab.org
http://lists.logilab.org/mailman/listinfo/python-projects