While investigating Ruby I came across this to create a simple Struct-like class:
Person = Struct.new(:forname, :surname)
person1 = Person.new(\'John\', \'Do
The Python package esu brings a struct that can provide almost the same functionality:
from esu import Struct
Customer = Struct(
'Customer',
'name', 'address',
methods={
'greeting': lambda self: "Hello {}".format(self.__dict__['name'])
})
dave = Customer()
dave.name = 'Dave'
dave.greeting() # => Hello Dave
from https://torokmark.github.io/post/python-struct/