[Tutor] New class, how return value of x in interactive shell

Alan Gauld 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
>    @classmethod
>    def new(cls, x):
>        """ :param x: a (biological) string """
>        res = cls(cls._bstring_constructor(conversion.py2ri(x)))
>        _setExtractDelegators(res)
>        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__()?

Alan Gauld
Author of the Learn to Program web site

More information about the Tutor mailing list