[Tutor] How to call a method with a print statement?

Jeff R. Allen jra at nella.org
Thu Nov 12 12:29:27 CET 2009


You are looking for the __str__ method. See
http://docs.python.org/reference/datamodel.html#object.__str__

class Foo():
  def __init__(self):
     pass

  def  __str__(self)
     return "hello world!"

  -jeff


More information about the Tutor mailing list