Pre-PEP ideas

Greg Ewing (using news.cis.dfn.de) me at privacy.net
Tue Feb 18 18:54:16 EST 2003


Alex Martelli wrote:

> And why, even then, would the reasonably simple style:
> 
> def _A__pprint(self):
>     print self._value
> A.pprint = _A_pprint
> 
> be so bad as to warrant a syntax addition to Python?


Because it's far too ugly a thing to use on a
regular basis.


Ian Bicking wrote:
> you are implying there should be an entirely different style
> of source file.  A file like:
>
> class A: pass
> 
> def A.__init__(self):
>    ...

Yes, although I'm a bit uncomfortable about it myself

now that I come to think about it. Having all your class
definitions empty would seem a bit strange in Python.

Maybe a compromise would be to optionally allow the
class name to be specified, but still require the def
to be inside the class -- the compiler would check that
the name used actually matches the class it's in.


  class A:


     def A.__init__(self):
       ...

     def B.blarg(self, x): # Syntax error - wrong class name
       ...



-- 
Greg Ewing, Computer Science Dept,
University of Canterbury,	
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg





More information about the Python-list mailing list