Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Hartmut Goebel Newsgroups: de.comp.lang.python Subject: Re: [Python-de] "property-init"-decorator Date: Sun, 31 May 2020 10:13:43 +0200 Organization: Goebel Consult Lines: 41 Message-ID: References: <875zci8zut.fsf@orrococo> <4719790.vIyLdRSyTD@palindrom> <9d687032-db10-2482-9455-540de7c9a3a4@goebel-consult.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: news.uni-berlin.de A3XksIf56vXm2gPZAr3KXghA79oqQQto5rPBbrK+Yrqg== Return-Path: X-Original-To: python-de@python.org Delivered-To: python-de@mail.python.org Authentication-Results: mail.python.org; dkim=none reason="no signature"; dkim-adsp=none (unprotected policy); dkim-atps=neutral X-Virus-Scanned: amavisd-new at mnet-online.de User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 In-Reply-To: <4719790.vIyLdRSyTD@palindrom> Content-Language: de-DE X-Content-Filtered-By: Mailman/MimeDel 2.1.33 X-BeenThere: python-de@python.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: Die Deutsche Python Mailingliste List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <9d687032-db10-2482-9455-540de7c9a3a4@goebel-consult.de> X-Mailman-Original-References: <875zci8zut.fsf@orrococo> <4719790.vIyLdRSyTD@palindrom> Xref: csiph.com de.comp.lang.python:5640 Am 27.05.20 um 17:13 schrieb Peter Otten: > Die Reihenfolge kann durch die Positionierung in der Klasse bestimmt werden: Könnte man machen, allerdings würde ich mich nicht darauf verlassen, dass die Reihenfolge in `vars(A).keys()` immer stimmt. Kannst Du mit eine Doku dazu zeigen, ich habe nichts gefunden. Allerdings hat mich Deine Mail noch auf einen ganz anderen Ansatz gebracht: class A:     _myprop = 1.23     @property     def myprop(self):         return self._myprop     @myprop.setter     def myprop(self, value):         if value < 2.5:             self._myprop = value a = A() print(a.myprop) a.myprop = 2.1 print(a.myprop) -- Schönen Gruß Hartmut Goebel Dipl.-Informatiker (univ), CISSP, CSSLP, ISO 27001 Lead Implementer Information Security Management, Security Governance, Secure Software Development Goebel Consult, Landshut http://www.goebel-consult.de Blog: https://www.goe-con.de/blog/35.000-gegen-vorratdatenspeicherung Kolumne: https://www.goe-con.de/hartmut-goebel/cissp-gefluester/2011-09-kommerz-uber-recht-fdp-die-gefaellt-mir-partei