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

2010-04-05 Thread Alan Gauld
"Vincent Davis" 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))) _setExtractDelegato

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

2010-04-05 Thread Alan Gauld
"Vincent Davis" wrote Take a look at the repr and str methods: http://docs.python.org/reference/datamodel.html#basic-customization Ok so I am still a little confused, It seems that __str__ is used for print and str() That's right and repr() is used when evaluating the object, as at the >>

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

2010-04-05 Thread Vincent Davis
> > 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 home

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

2010-04-05 Thread Alan Gauld
"Vincent Davis" 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:>>> in:>>>print(b) out:

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

2010-04-05 Thread Vincent Davis
Take a look at the repr and str methods: http://docs.python.org/reference/datamodel.html#basic-customization Ok so I am still a little confused, It seems that __str__ is used for print and str() byt what allows whats below. That is why does just entering the name of the instance return print(b).

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

2010-04-05 Thread Wayne Werner
On Mon, Apr 5, 2010 at 12:08 PM, Vincent Davis 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') > out: >>>b > in:>>> > in:>>>print(b) > out: >>> 21-letter "BString" instance >

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

2010-04-05 Thread Vincent Davis
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') out: >>>b in:>>> in:>>>print(b) out: >>> 21-letter "BString" instance seq: I am a BString object What I would like is to be ab