vendredi 21 mai 2021

Python best pratice to create a nested or chian methods [closed]

I am creating a class in Ptyhon with several attribues. I am looking for a Design Pattersn (if exist) or technique to improve the following example.

I wish to get specific nested and/or chain methods as

MyClass.Info.Ancillary
MyClass.Info.Header

if you choose MyClass.Info.Ancillary you have sub-methods, for instance:

MyClass.Info.Ancillary.GyroData
MyClass.Info.Ancillary.PSVdata

if you choose MyClass.Info.Ancillary.GyroData you have sub-sub-methods, for instance

MyClass.Info.Ancillary.GyroData.Gyro_1
MyClass.Info.Ancillary.GyroData.Gyro_2

and so on

Aucun commentaire:

Enregistrer un commentaire