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

Vincent Davis vincent at vincentdavis.net
Mon Apr 5 19:08:54 CEST 2010


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:    >>><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?

I have a lot to learn so pointing me in the right direction or to
documentation is as useful as the correct code.

Thanks

  *Vincent Davis
720-301-3003 *
vincent at vincentdavis.net
 my blog <http://vincentdavis.net> |
LinkedIn<http://www.linkedin.com/in/vincentdavis>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100405/746f4422/attachment.html>


More information about the Tutor mailing list