a new object definition

Sylvain Ferriol sferriol at imag.fr
Fri Sep 1 04:28:41 EDT 2006


hello everybody,

i want to talk with you about a question i have in mind and i do not
find a answer. it 's simple:
why do we not have a beatiful syntax for object definition as we have
for class definition ?

we can define a class in python in 2 ways:
  1. by using the metaclass constructor
    my_class = MyMetaClass(....)
  2. by using the classic definition syntax:
    class my_class(object):
       __metaclass__ = MyMetaClass

if i want to instanciate an object, i only have one way to define it:
  my_obj = my_class(....)

why not a better syntax like class syntax ?

example:
>> instance my_obj:
>>   __class__ = my_class


with this syntax, we are coherent between objects and classes.
why do we have a specific syntax for the class object definition and not
for objects of different type?

so if i want to define a new class object (my_class for example) with a
new object syntax:
>> instance my_class:
>>   __class__ = object
>>   __metaclass__ = MyMetaClass
>>   ....

thanks

Sylvain Ferriol
Ingénieur de recherche
Laboratoire TIMC/IMAG
http://www-timc.imag.fr/




More information about the Python-list mailing list