Python Forum
setting base class attribute
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
setting base class attribute
#1
how can i ensure that an attribute can only be set from derived class? if some other class tries to set it, it should be illegal
Reply
#2
Please, give more information. What you're describing doesn't make sense for something you should need to worry about, as a parent object should never care what "extra" baggage derived/child classes add on. That's sort of the whole point of having derived classes, after all, adding functionality to a base class.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Initiating an attribute in a class __init__: question billykid999 8 1,314 May-02-2023, 09:09 PM
Last Post: billykid999
  Dynamically setting nested class be_ams 0 1,508 Apr-06-2022, 02:09 PM
Last Post: be_ams
  class, attribute and method Frankduc 9 2,459 Feb-27-2022, 09:07 PM
Last Post: deanhystad
  Calling a base class variable from an inherited class CompleteNewb 3 1,676 Jan-20-2022, 04:50 AM
Last Post: CompleteNewb
  Importing issues with base class for inheritance riccardoob 5 4,672 May-19-2021, 05:18 PM
Last Post: snippsat
  Python generics: How to infer generic type from class attribute? Thoufak 0 2,814 Apr-25-2021, 09:31 AM
Last Post: Thoufak
  AttributeError class object has no attribute list object scttfnch 5 3,419 Feb-24-2021, 10:03 PM
Last Post: scttfnch
  Behavior of Abstract Base Class dgrunwal 4 2,168 Oct-15-2020, 07:19 PM
Last Post: Gribouillis
  "can't set attribute" on class DreamingInsanity 2 10,859 Aug-22-2020, 07:57 PM
Last Post: DreamingInsanity
  how can I changing a base class method voidptr 2 2,256 Nov-10-2019, 10:53 PM
Last Post: voidptr

Forum Jump:

User Panel Messages

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