osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

about types.new_class and module


Thank you for the clarification.

I thought everything was bounded to anything.

Shouldn't the name be changed from `types.A` to `unbound.A` to be less 
confusing ?

Le 04/03/2019 ? 20:31, MRAB a ?crit :
>>
> 'new_class' creates a new class with the given name and returns a 
> reference to it.
>
> The class doesn't 'live' anywhere.
>
> Although you might /think/ that an object lives in a certain 
> namespace, it's just that there's a name there that's bound to the 
> object.
>
> You can, in fact, create 2 classes with the same name.
>
> >>> import types
> >>> t1 = types.new_class('A')
> >>> t2 = types.new_class('A')
> >>> t1 is t2
> False