Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
strange class property
#1
Why does the following program output "python is hard" ?
class t:
    def __init__(self):
        self.__t="python is hard"
t=t()
print(t._t__t)
Reply
#2
check https://dbader.org/blog/meaning-of-under...-in-python
in particular - part 3. Double Leading Underscore: __var
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
Thanks!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Subclass initialized property used in parent class method. Is it bad coding practice? saavedra29 5 1,685 Feb-07-2022, 07:29 PM
Last Post: saavedra29
  ABC Module and @property decorator, Pythonic Way? muzikman 21 5,564 Aug-18-2021, 06:08 PM
Last Post: muzikman
  @property vs __set__ / __get__ and __setattr__ / __getattr__ okhajut 1 3,256 Jun-15-2021, 03:48 PM
Last Post: snippsat
  Can property getters and setters have additional arguments? pjfarley3 2 2,993 Oct-30-2020, 12:17 AM
Last Post: pjfarley3
  Property price calculation oli_action 4 3,092 Jul-15-2020, 04:27 PM
Last Post: sridhar
  Use of @property decorator ruy 16 6,418 Jun-09-2020, 05:29 PM
Last Post: buran
  Problem adding keys/values to dictionary where keynames = "property" and "value" jasonashaw 1 2,019 Dec-17-2019, 08:00 PM
Last Post: jasonashaw
  print all method and property of list object engmoh 4 2,802 Oct-26-2019, 05:33 PM
Last Post: engmoh
  group by property bhojendra 25 8,177 Jul-01-2019, 08:45 PM
Last Post: perfringo
  what is the doc parameter of property? microphone_head 2 2,444 Apr-11-2019, 08:59 AM
Last Post: microphone_head

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020