> On 23 Jul 2023, at 02:12, Chris Nyland via Python-list
> wrote:
>
> So I am stuck on a problem. I have a class which I want to use to create
> another class without having to go through the boiler plate of subclassing.
> Specifically because the subclass needs to have certain class attributes
> and I would like to control how those are passed to provide defaults and
> such. What I have working right now is
> class Foo():
>@classmethod
>def method_a(cls): print(cls.name)
>
> Bar = type('Bar', (Foo,), {'name': 'test1’})
Could you write a more expressive example of what you are trying to do and what
the problem actually is?
The way you wrote the above doesn’t contain any clues why usual subclassing is
not appropriate.
By attributes you mean value attributes or methods? Why going the usual route
of subclassing & controlling their behaviour via constructor arguments isn’t
working?
> This is sort of fine but the user needs to know how to call type and
> include all the base classes etc.
I don’t get what you mean by this either. Very hard to follow everything that
went after, given I was lost at this point.
Maybe it’s only me... But I if you clarified these, I might be able to help a
bit.
DG
--
https://mail.python.org/mailman/listinfo/python-list