Attention is currently required from: laforge, neels.

fixeria has posted comments on this change by neels. ( 
https://gerrit.osmocom.org/c/pysim/+/39741?usp=email )

Change subject: [1/6] personalization: refactor: drop ClassVarMeta use
......................................................................


Patch Set 6:

(1 comment)

Patchset:

PS6:
> Name: […]
So many letters here... is it a comment by Mychaela? Oh, no, it's Neels!

Just a few cents from me: if properly implemented, a metaclass allows you to 
pass variables in both ways:

```
# like this
class Foo(metaclass=MetaFoo, a=1, b=2):
    ''' ... '''

# and like this
# like this
class Foo(metaclass=MetaFoo):
    a = 1
    b = 2

# or both at the same time
class Foo(metaclass=MetaFoo, a=1):
    b = 2
```

This can be achieved as follows:

```
class MetaFoo(abc.ABCMeta):
    def __new__(mcs, name, bases, namespace, **kwargs):
        x = super().__new__(mcs, name, bases, namespace)
        x.a = namespace.get('a', kwargs.get('a', None))
        x.b = namespace.get('b', kwargs.get('b', None))
        return x
```

A good example is `ApduCommandMeta`.



--
To view, visit https://gerrit.osmocom.org/c/pysim/+/39741?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I60ea8fd11fb438ec90ddb08b17b658cbb789c051
Gerrit-Change-Number: 39741
Gerrit-PatchSet: 6
Gerrit-Owner: neels <nhofm...@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: fixeria <vyanits...@sysmocom.de>
Gerrit-CC: laforge <lafo...@osmocom.org>
Gerrit-Attention: neels <nhofm...@sysmocom.de>
Gerrit-Attention: laforge <lafo...@osmocom.org>
Gerrit-Comment-Date: Fri, 14 Mar 2025 08:53:25 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: neels <nhofm...@sysmocom.de>
Comment-In-Reply-To: laforge <lafo...@osmocom.org>

Reply via email to