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

Modulok modulok at gmail.com
Thu Nov 12 11:31:54 CET 2009


List,

How do I get a print statement to call a class method? I'm using
python 2.5. I did it long ago, but can't remember how, or even where I
learned it from. Something like:

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

   def  ***part I can't remember goes here***
      print "hello world!"

 # Now use it:
bar = Foo()
print bar
hello world! #<-- Magic!


If any of this makes sense, any pointers would be great!
-Modulok-


More information about the Tutor mailing list