Hi,

I often find myself writing:

  class grouping:

      def __init__(self, x, y, z):
          self.x = x
          self.y = y
          self.z = z

I hate it, and every time I show this to a Python newcomer I get that
skeptic look. How about this for a change?

  class grouping:

      def __init__(self, .x, .y, .z):
          pass

This is supposed to work the same way as:

      def __init__(self, x, y, z):
          self.x = x
          del x
          self.y = y
          del y
          self.z = z
          del z

Currently the .x syntax leads to:

      def __init__(self, .x, .y, .z):
                         ^
  SyntaxError: invalid syntax

I.e. it seems to me that there shouldn't be any backward compatibility
issues.

I'll write a PEP if I hear a few voices of support.
(Otherwise I'll stick to my "adopt_init_args" workaround:
http://phenix-online.org/cctbx_sources/libtbx/libtbx/introspection.py
which does a similar job but doesn't look as elegant and is also
quite inefficient).

Cheers,
        Ralf
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to