Constructors

Hi I got really confused when I learned the page 18 of the Constructors part.
The answer was this:

class Circle:
  pi = 3.14

  # Add constructor here:

  def __init__(self, diameter):

    print("New circle with diameter: {diameter}".format(diameter=diameter))

teaching_table = Circle(36)

My question is why before it suggested us to use return"string" but now use print("string) instead?
And I try using return, it showed this - TypeError: init() should return None, not ‘str’

The other question is why before it used like

teaching_table = Circle()
teaching_table.__init__(36)

But now when I used it, it showed
init() missing 1 required positional argument: ‘diameter’

really confusing it is, plz help me

Hi there, welcome back to the forum!

Without knowing which exercise you’re referring to with “before”, I can’t be certain. However, nothing should have been telling you to return a specific value from an __init__() method. Doing so gives you the error you’re seeing. __init__() is a special function, whose only job is to initialise the object. It should return None.

Where was that shown? :slight_smile: