Python Forum
Unchangeable variables in a class?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unchangeable variables in a class?
#11
Might could do something like this to keep from setting the value the way I did

@property
    def double(self):
        if self._double != self._value * 2:
            raise AttributeError
        return self._double
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags
Download my project scripts


Reply


Messages In This Thread
Unchangeable variables in a class? - by Calab - Sep-15-2023, 02:27 PM
RE: Unchangeable variables in a class? - by Calab - Sep-15-2023, 02:55 PM
RE: Unchangeable variables in a class? - by Calab - Sep-15-2023, 03:48 PM
RE: Unchangeable variables in a class? - by menator01 - Sep-15-2023, 04:15 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Class variables and Multiprocessing(or concurrent.futures.ProcessPoolExecutor) Tomli 5 6,504 Nov-12-2021, 09:55 PM
Last Post: snippsat
  How to pass variables from one class to another hobbyist 18 20,055 Oct-01-2021, 05:54 PM
Last Post: deanhystad
  Acess variables from class samuelbachorik 3 2,642 Aug-20-2021, 02:55 PM
Last Post: deanhystad
  Class variables menator01 2 2,789 Jun-04-2020, 04:23 PM
Last Post: Yoriz
  Question about naming variables in class methods sShadowSerpent 1 2,691 Mar-25-2020, 04:51 PM
Last Post: ndc85430
  Understanding Class Variables vindo 9 5,607 Jun-05-2019, 08:04 PM
Last Post: Yoriz
  What is the strategy for working with class variables? AlekseyPython 3 3,748 Feb-24-2019, 05:34 AM
Last Post: AlekseyPython
  Base class variables are not accessible Prabakaran141 3 3,742 Oct-31-2018, 07:13 AM
Last Post: buran
  Class Modules, and Passing Variables: Seeking Advice Robo_Pi 21 13,956 Mar-02-2018, 05:22 PM
Last Post: snippsat
  Running Class methods in a loop and updating variables. ujjwalrathod007 3 7,950 Oct-05-2016, 07:11 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

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