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

Vincent Davis vincent at vincentdavis.net
Mon Apr 5 21:17:44 CEST 2010


>
> That' a very strange idiom in Python.
> Can you show us the class definition?


It's a bioconductor extension to rpy2
http://www.bitbucket.org/lgautier/rpy2-bioc-extensions/overview/
I am trying to learn R and at they same time more about python and R
bioconductor packages. So no it is not homework but I am trying to learn
something. I am sure the answer is obvious when you know it :)
Here is the class, although it is obviously part of something bigger, you
can checkout the full code at bitbuckit.org

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

*Vincent Davis
720-301-3003 *
vincent at vincentdavis.net
 my blog <http://vincentdavis.net> |
LinkedIn<http://www.linkedin.com/in/vincentdavis>


On Mon, Apr 5, 2010 at 1:08 PM, Alan Gauld <alan.gauld at btinternet.com>wrote:

> "Vincent Davis" <vincent at vincentdavis.net> wrote
>
>> I am working an a open source project and would like to add feature to a
>>
>> class.
>> Current action:
>> in:    >>>b = BString.new('I am a BString object')
>>
>
> That' a very strange idiom in Python.
> Can you show us the class definition?
>
>
>  out:  >>>b
>> in:    >>><BString - Python:0x1044846c8 / R:0x105c86f50>
>> in:    >>>print(b)
>> out:  >>> 21-letter "BString" instance
>>              seq: I am a BString object
>>
>> What I would like is to be able to
>> in   >>>b
>> out >>>21-letter "BString" instance
>>              seq: I am a BString object
>>
>> I have 2 questions
>> 1, how do I do this?
>> 2, how does print know what to do?
>>
>
> If you look at your class definition that should become obvious.
> Are you sure this isn't a homework?
>
>
> --
> Alan Gauld
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100405/381f2cd8/attachment.html>


More information about the Tutor mailing list