Rob. Sweet!  Many thanks.

Regards,
David

On Nov 29, 2008, at 1:46 PM, Rob Williscroft wrote:

David Pratt wrote in news:mailman.4664.1227980181.3487.python-
[EMAIL PROTECTED] in comp.lang.python:

import new

class FirstBase(object):
     foo = 'bar'
     biz = 'baz'

class SecondBase(object):
     bla = 'blu'
     buz = 'brr'

attr = {
     'fiz': 'An attribute', 'fuz': 'Another one'}

Test = new.classobj(
     'Test', (FirstBase, SecondBase), attr)

Test = type(
     'Test', (FirstBase, SecondBase), attr)


class MyNewClass(Test):
     pass

a = MyNewClass()

print a.foo, a.buz, a.fiz, type(a)

print( ( a.foo, a.buz, a.fiz, type(a) ) )

py 3.0:
        ('bar', 'brr', 'An attribute', <class '__main__.MyNewClass'>)
py 2.4
        ('bar', 'brr', 'An attribute', <class '__main__.MyNewClass'>)

Rob.
--
http://www.victim-prime.dsl.pipex.com/
--
http://mail.python.org/mailman/listinfo/python-list

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to