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


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

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 Wed, 27 May 2020 10:27:31 +0200
Organization Goebel Consult
Lines 40
Message-ID <mailman.148.1590568630.27263.python-de@python.org> (permalink)
References <875zci8zut.fsf@orrococo> <c36dda0a-50b6-7454-2da4-1f3bff5828cf@goebel-consult.de>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
X-Trace news.uni-berlin.de nPOfoEm5FC+tw1UN3eOo0gq6rH2hQqrBBpDUK2fzokOQ==
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 <875zci8zut.fsf@orrococo>
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 <c36dda0a-50b6-7454-2da4-1f3bff5828cf@goebel-consult.de>
X-Mailman-Original-References <875zci8zut.fsf@orrococo>
Xref csiph.com de.comp.lang.python:5636

Show key headers only | View raw


Am 26.05.20 um 17:44 schrieb Оlе Ѕtrеісhеr:
> Wie bringt man die enger zusammen? Ein @myprop.init gibt es ja
> offensichtlich nicht und kann man auch nicht so ohne weiteres anlegen,
> oder? Oder was wäre ein sinnvolles Pattern hier?

Du könntest eine eigene "Property" class implementieren, die einen
weiteren Docorator "initialisiere" hat.  Allerdings bleibt immer noch
das Problem, dass Du diese Funktion in __init__ irgendwie aufrufen
musst. Du müsstest in __init__ hergehen und alle properies der Klasse
(self.__class__) finden und deren initalizer aufrufen.

Ich habe die genau Funktionsweise von Properties nicht im Kopf, aber
irgendwie sollte das gehen. Vielleicht schaust Du man in den PEP zu
properties, dort gibt es sicher Details.

Allerdings gibt es mindestens zwei Haken:

1. Wenn die initializer in eine bestimmten Reihenfolge aufgerufen werden
müssen, dann musst Du sie doch wieder benennen. Denn sonst bekommstt Du
keine Reihenfolge.

2. Wie ruft man die iniatlizer überhaupt auf?

-- 
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/dsl-fernkonfiguration-ist-kritisch-fur-den-datenschutz

Kolumne:
https://www.goe-con.de/hartmut-goebel/cissp-gefluester/2011-02-fleisige-datensammler-fur-lukratives-geschaeftsmodell-gesucht

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