Instantiaating your first object


what is the difference
although output is the same

class Animal(object):
  def __init__(self,name): = name 
    zebra = Animal("Jeffrey")
class Animal(object):
    def __init__(self,name): = name 
zebra = Animal("Jeffrey")
    #used no indentation.


the first code should give an error, you are still defining the class. You can't instantiate a class inside the class (given you are still defining a class).

instances should be created outside the class


thank you very much, i understood now..
object oriented programming is little weird..
and its a little tough
any other good resources.?
i tried sololearn but not so great


sololearn is good, its just fast paced

I learned from all over the place, i am sure you can find more resources using google


solo learn is great but with OOP is not explained well ,
i am now also reading from" learning python the hard way.." which looks simplified...version


i wouldn't go this far, i would stay with its fast paced

you can always check the official docs on classes:

learn python the hard way is also good


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.