Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > de.comp.lang.python > #5640

Re: [Python-de] "property-init"-decorator

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Hartmut Goebel <h.goebel@goebel-consult.de>
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 <mailman.43.1590913385.24731.python-de@python.org> (permalink)
References <875zci8zut.fsf@orrococo> <c36dda0a-50b6-7454-2da4-1f3bff5828cf@goebel-consult.de> <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 <h.goebel@goebel-consult.de>
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 <python-de.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-de>, <mailto:python-de-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-de/>
List-Post <mailto:python-de@python.org>
List-Help <mailto:python-de-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-de>, <mailto:python-de-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <9d687032-db10-2482-9455-540de7c9a3a4@goebel-consult.de>
X-Mailman-Original-References <875zci8zut.fsf@orrococo> <c36dda0a-50b6-7454-2da4-1f3bff5828cf@goebel-consult.de> <4719790.vIyLdRSyTD@palindrom>
Xref csiph.com de.comp.lang.python:5640

Show key headers only | View raw


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

Back to de.comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

"property-init"-decorator ole-usenet-spam@gmx.net (Оlе Ѕtrеісhеr) - 2020-05-26 17:44 +0200
  Re: [Python-de] "property-init"-decorator Julian Gethmann <mail.python.org@gethmann.org> - 2020-05-26 18:07 +0200
  Re: [Python-de] "property-init"-decorator Hartmut Goebel <h.goebel@goebel-consult.de> - 2020-05-27 10:27 +0200
  Re: "property-init"-decorator "Andreas B." <ab@sysing.de> - 2020-05-27 13:18 +0200
  Re: [Python-de] "property-init"-decorator Gregor Engberding <gregor@landit.de> - 2020-05-27 17:04 +0200
  Re: [Python-de] "property-init"-decorator Peter Otten <__peter__@web.de> - 2020-05-27 17:13 +0200
  Re: [Python-de] "property-init"-decorator Hartmut Goebel <h.goebel@goebel-consult.de> - 2020-05-31 10:13 +0200
  Re: [Python-de] "property-init"-decorator Peter Otten <__peter__@web.de> - 2020-05-31 15:37 +0200

csiph-web