from
Mateusz Łoskot <mateusz at loskot dot net>
to
Python-Projects <python-projects at lists dot logilab dot org>
subject
Re: [Python-projects] Not enough public methods
date
Fabien Schwob wrote:2006/01/16 21:07
>
> 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
