What's wrong with this code snippet?
Alex Martelli
aleax at mail.comcast.net
Sat Jan 7 13:41:51 EST 2006
LordLaraby <Lord.Laraby at gmail.com> wrote:
> For what it's worth, GenerateRandomColour does not access any instance
> variables and therefore needn't even be a member of the class
> Population. If you wanted it there for encapsulation purposes, consider
> making it a staticmethod like so:
>
> @staticmethod()
> def GenerateRandomColour():
> rn.seed()
> colour = rn.choice(['C', 'P', 'Z'])
> return colour
No parentheses on the decorator line, just '@staticmethod'. Otherwise,
fine.
Alex
More information about the Python-list
mailing list