> I have created a dynamic class using the type() function:
> x = type('MyFlags', (), {'Flag1': 1, 'Flag2': 2, 'Flag3: 4, ' '__init__' :
> __init__})
I find that it's generally more convenient to do this using similar code:
def constructor(flag1, flag2):
class _Hidden:
def __init__(se
On 20/05/25 4:33 am, Stefan Ram wrote:
So, the reason you're getting that
TypeError is your __init__ function isn't actually hooked up
right when you build your class with "type". You got to set up
your init before you call "type", and then drop it into the
class dictionary as a /f
On 19/05/2025 23:11, Thomas Passin via Python-list wrote:
On 5/19/2025 5:49 PM, Mats Wichmann via Python-list wrote:
On 5/19/25 09:51, Jonathan Gossage via Python-list wrote:
I have created a dynamic class using the type() function:
x = type('MyFlags', (), {'Flag1': 1, 'Flag2': 2, 'Flag3: 4,
On 5/19/2025 5:49 PM, Mats Wichmann via Python-list wrote:
On 5/19/25 09:51, Jonathan Gossage via Python-list wrote:
I have created a dynamic class using the type() function:
x = type('MyFlags', (), {'Flag1': 1, 'Flag2': 2, 'Flag3: 4, '
'__init__' :
__init__})
The new class is there, and the c
On 5/19/25 09:51, Jonathan Gossage via Python-list wrote:
I have created a dynamic class using the type() function:
x = type('MyFlags', (), {'Flag1': 1, 'Flag2': 2, 'Flag3: 4, ' '__init__' :
__init__})
The new class is there, and the class variables, Flag1, Flag2, and Flag3,
are present correctly
Duh! how dumb am I? A dictionary solves all those problems, with each
entry named, and the value of each name could be a class instace. plus all
the class instances can be iterated by a loop.
Thanks Piet & Alex for your guidance!
-Dave
"Piet van Oostrum" <[EMAIL PROTECTED]> wrote in message
> "Dave Rose" <[EMAIL PROTECTED]> (DR) wrote:
>DR> Hello all.
>DR> I was wondering if creating classes could be dynamic. I want to know
>DR> if I can make a class Person, then read in a list of names (say
>DR> people's names) so then I can have a class instance created for each
>DR> name in
Dave Rose <[EMAIL PROTECTED]> wrote:
> Hello all.
> I was wondering if creating classes could be dynamic. I want to know if I
> can make a class Person, then read in a list of names (say people's names)
> so then I can have a class instance created for each name in the list?
Yes, but what you'