Learn Python programming in TAMIL |Encapsulation - public and private variable - Part 2 | [Tamil]

Поділитися
Вставка
  • Опубліковано 14 гру 2024

КОМЕНТАРІ • 10

  • @joyson7379
    @joyson7379 Рік тому +1

    mam private variable ah function ku veliya use panna mutiyalaye.ana ni use pannalam nu solriga

  • @அருண்குமார்-ர5ள

    4:00 method ku veliya (class ku ulla ) obj va vachu public variablea access panna mudiyala mam. Attribute Error varuthu mam. Please explain this mam💖

    • @அருண்குமார்-ர5ள
      @அருண்குமார்-ர5ள Рік тому +2

      class test:
      def detail(self,name,age):
      self.name=name
      self.age=age
      print("Name: ",obj.name)
      print("Age: ",obj.age)
      obj=test()
      obj.detail("arun",23)
      print("Name: ",obj.name)
      print("Age: ",obj.age)
      Output: AttributeError: 'text' object has no attribute 'name'

    • @அருண்குமார்-ர5ள
      @அருண்குமார்-ர5ள Рік тому +1

      Please explain this mam

    • @GURUKULA
      @GURUKULA  Рік тому

      @@அருண்குமார்-ர5ள yes we are getting attribute error... in video it works fine.. because we have run the previous code so the next block of code runs properly.... but when we run the specific code block it shows error... it is because when we put print statement outside a function and within a class it will executed even before the object is created so we are getting that error....
      class test:
      def detail(self):
      pass
      print("hai")
      If you run the above code you will get output hai..... here the print statement is executed as soon as we create and run the class even without creating the object...
      like wise when we run our previous code,
      print("Name: ",obj.name)
      print("Age: ",obj.age)
      the obj will not be created at that time of execution so we are getting that error... if you put the same print statements in another method it will work fine...

    • @sharpcreation6908
      @sharpcreation6908 Рік тому

      Mam jupyter notebook show output properly but python 3.11 idle was showing name error in this method

    • @sharpcreation6908
      @sharpcreation6908 Рік тому +1

      ​@@GURUKULAmam if you don't mind can you make one more video about public variable because public variable access method outside in jupyter notebook it was showing output without error but the same code run to python (idle,3.11) it's showing name error

  • @Orthodoxpottan
    @Orthodoxpottan Рік тому +1

    Akka protected concept encapsulation la fasta podunga pls