Anonymous class question
Bengt Richter
bokr at oz.net
Thu Aug 7 21:11:40 EDT 2003
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
More information about the Python-list
mailing list