The perfect Python
Pekka Niiranen
krissepu at vip.fi
Wed Aug 28 15:13:10 EDT 2002
Instead of the features you listed I think developers should
concentrate more on speeding up the execution of Python code.
The trend of making C -extensions for the sake of the cleaner syntax
does not make sense: are we to convert all the existing C-code to Python
callable procedures? What happens to the maintainability of this
kind of "Python" -code?
Beautiful syntax but no oomph.
-pekka-
Jean-François Ménard wrote:
>First, a warning:
> - I'm very poor in english.
> - I woke up way too early this morning.
> - It's a long post... (Sorry!)
> - I *love* python. This is not a troll, or anything like that.
>
>Ok. Here we go.
>
>I would like to share my impressions and my comments on Python. At the end,
>I will propose what would be for me the *perfect* Python interpreter.
>
>Background:
>
>I'm working on a fairly big Python (Zope) project since a year and a half.
>It's a content management system for a big (19 000 employees) entreprise.
>At first, I was the sole developper for the project. My orders were: "Ok,
>choose what you want, do what you want. We just want one thing: results..."
>Lucky, hey? ;)
>
>I had experience in Object Pascal (Delphi), Vb (...), C++ and Java. I was
>new in the company, and wanted to impress my bosses. After some research, I
>narrowed my choices to two options: EJB (Java) and Zope (Python).
>
>I gave a serious look at EJB, but in the end, I chose Python. I took a
>risk. I don't regret it. After only 2 months, I had already produced a
>working system. Alone... :)
>
>Opinions, impressions:
>
>At first, I was amazed by the simplicity and the clarity of the syntax. I
>*love* the indentation style. It gives clean and standardized source code.
>We are now three developpers on the project, and it's easy for anyone of us
>to understand the code of the others.
>
>But...
>
>As project grew up, I started to see some of the limitations of the
>language. I understand that Python was not designed for such big projects.
>But it's so powerfull, so clean, that I just wonder what Python could become
>with just some (ok, not so minors...) improvements.
>
>I understand that backward compatibility is important too, but the latests
>extensions to Python begin to seem locked by past decisions. I don't like
>this tendency to __this__ and __that__ everything. We loose in readability,
>accessibility and clarity, in my opinion...
>
>The Perfect Python (c):
>
>What is missing ? Well, I'm not a language designer, but I can say what *I*
>miss.
>
> - Interfaces. Behavior checking is not enough.
> - Private and Public scopes. Explicitly. No more __name_mangling
> - Design by contract. Pre and Post conditions. Could save hours of
>debugging.
> - Block comments. """ """ should be for documentation.
> - Class variables.
> - A cleaner Property declaration. No separate _variable. Saw too many
>newbie posts about that.
> - No more self in functions declarations. In OOP, this *can* be
>implicit. (I know, this is controversial stuff)
> - Standard GUI library. AnyGui seems to be the solution, but
>development seems to have stalled recently...
>
>I tried to write an example of what Perfect Python(c) could look like. It's
>not valid code (duh!), and it does'nt try to do anything unless give a
>sample syntax:
>********************
>from package1.package2 import module1, module2
>
>public interface MyInterface implements (OtherInterface1, OtherInterface2):
> """ Comments """
> private PrivateClassVariable
> public property MyProperty
> public MyFunction(param1, param2)
>
>public class MyClass(Class1, Class2) implements MyInterface, Interface2:
> """ Comments """
>
> # Instance Variable
> private InstanceVariable = "Default"
>
> # Class Variable - Public by default
> static PublicClassVariable = "Default"
>
> # Class Variable - Private
> static private PrivateClassVariable = "Default"
>
> public initialize(param1, param2="", param3=None):
> """ Comments """
> # OtherInstanceVariable is Public by default
> self.OtherInstanceVariable = "rien"
>
> # OtherInstanceVariable2 - Private
> private self.OtherInstanceVariable = "rien"
>
> private MyFunction(MyParameter1, MyParameter1):
> """ Comments """
> return "Result"
>
> /*
> Block comment
>
> function Foo():
> pass
> */
>
> public property MyProperty:
> """ Comments """
> get():
> """ Comments """
> return self.MyProperty
> set(newValue):
> """ Comments """
> self.MyProperty = newValue
>
> private testInterface(otherObject):
> """ Interface checking """
> # Check for interface implementation
> if otherObject implements MyInterface:
> return true
>
> # Check for multiple interface implementation
> if otherObject implements (OtherInterface1 or OtherInterface2):
> return true
>
> # Check for class inheritance
> if otherObject implements MyInterface:
> return true
>
> return false
>
> private testInheritence(otherObject):
> """ Inheritence checking """
> # Check for class inheritance
> if otherObject implements MyInterface:
> return true
>
> private propertyCall():
> """ Uniform call """
> return self.MyProperty
>
> private propertySet(newValue):
> """ Uniform call """
> self.MyProperty = "new value"
>
> public functionWithAssertion(Param1):
> """ Design by Contract """
> require:
> """ Precondition """
> Param1 < 1000000
> do:
> """ Function body """
> pass
> ensure:
> """ Poscondition """
> Param1 < 1000000
>
>********************
>I have no idea how this could be implemented. Maybe a PerfectPython
>interpretor could be developped on top of the standard interpretor?
>
>Any comments? Anybody interested to start the project? ;)
>
>
More information about the Python-list
mailing list