Anonymous class question
Dan Williams
dan at osheim.org
Fri Aug 8 10:40:33 EDT 2003
Bengt Richter wrote:
> On Thu, 07 Aug 2003 03:20:24 GMT, Carl Banks <imbosol at aerojockey.com> wrote:
>
>
>>Dan Williams wrote:
>>
>>>Python experts,
>>>
>>>Is there a more pythonic way to do something evquilent to what this line
>>>does without creating a dummy class?
>>>
>>>self.file = type("", (object,), {'close':lambda slf: None})()
>>>
>>
> Does that (object,) do something I'm missing?
>
> >>> o1 = type('',(object,),{})()
> >>> o2 = type('',(),{})()
> >>> type(o1).__bases__
> (<type 'object'>,)
> >>> type(o2).__bases__
> (<type 'object'>,)
>
> Regards,
> Bengt Richter
I thought it made it a new-style class. I could be wrong about that,
though. . .
-Dan
More information about the Python-list
mailing list