[Tutor] New class, how return value of x in interactive shell
alan.gauld at btinternet.com
Mon Apr 5 22:03:24 CEST 2010
"Vincent Davis" <vincent at vincentdavis.net> wrote
> class BString(XString):
> """ Biological string """
> _bstring_constructor = biostrings.BString
> def new(cls, x):
> """ :param x: a (biological) string """
> res = cls(cls._bstring_constructor(conversion.py2ri(x)))
> return res
OK, I see what they are doing but as far as I can tell this could be
put in a __new__ method just as easily which would retain the
usual instantiation style.
Any gurus out there able to explain why they have used an
explicit new() class method rather than __new__()?
Author of the Learn to Program web site
More information about the Tutor