why not extending the syntax for classes, too ?

Michael Hudson mwh at python.net
Mon Feb 10 13:25:33 CET 2003

mis6 at pitt.edu (Michele Simionato) writes:

> > Your idea has a certain inconsistency: in the def the 'filter'
> > callable gets the whole function object.  In the class statement the
> > 'filter' gets the bits you need to make the class.
> ? Sorry, I do not understand what do you mean :-(

In your idea:

def filter(*args):
    print args

def func() is filter:

prints: <function func at 0xXXXXXXXXX>

class C is filter:

prints: ('C', (), {'__module__':'__main__'})

IOW lambda x:x works as a function filter but not as a class filter.

> > It also doesn't chain well, but given your preference of syntax, I
> > guess you don't care :-)
> > 
> I was thinking to chain with commas, as in
> class C is Traced,Profiled,Protected: #etc. etc.

Does that do the moral equivalent of

class _Foo(Traced,Profiled,Protected):

C = _Foo('C', (), {whatever})



  It is time-consuming to produce high-quality software. However,
  that should not alone be a reason to give up the high standards
  of Python development.              -- Martin von Loewis, python-dev

More information about the Python-list mailing list