Some notes

bearophile bearophileHUGS at lycos.com
Tue Oct 12 16:38:35 EDT 2004


This is my first post here, I hope this is the right place to talk
about such things. I have few comments and notes on the Python
language. I've just started to learn it; this is negative because I'm
ignorant still, but it's also positive because I can still see details
that later probably I'll start to ignore.

Some of the functions of IPython seem good and simple, and I think
some of them can be integrated into the main Python line.

There are lots of different ways to make GUIs for Python programs, I
think that Gui4Cli (http://users.hol.gr/~dck/g4c/) is nice, and it can
be interesting to see it more integrated with Python. At the moment
there is only this interface, but it's not good:
http://users.hol.gr/~dck/g4c/dll/python.htm

Is Python3000 going to come eventually? It will break a lot of
compatibility, so it will be the right moment to change/fix other
things too. Here are some ideas (probably there are errors, but I hope
to learn from my mistakes):

- TABs can be accepted only inside comments. 

- The optional static typing seems a quite nice thing (for compilers
too, they can produce faster code. It can probably allow faster and
smaller arrays, like those of numarray).

- The functional IF seems interesting, like:
if(cond, code1, code2)
(Or maybe a different syntax, that allows elseif too.)

- Functions containing yield can be defined in a different way, like:
generator name(params)
    <code>
This idea comes from David Mertz:
http://www-106.ibm.com/developerworks/library/l-pycon.html?n-l-9271

- "mod" can substitute the % operator. This gives cleaner (but a bit
longer) code.

- The string Formatting like %(#)03d can be good for C programs, but
probably can be invented a much simpler and nicer syntax for a high
level language like Python (does string.Template from 2.4 solve
this?). (Python is "based" on C, but putting C syntax inside Python
sometimes seems a bad thing to me.)

Maybe the : at the end of some blocks can be removed or it can become
optional (but then the newline is probably necessary):
for i in <suite>: <code>

for i in <suite>
    <code>

if <cond>
    <code>
else
    <code>

def name(params)
    <code>

- Assigns and equal symbols seem wrong/misplaced. So:
==  can become =
=  can become <-
the <- is probably a more correct symbol, but it can produce problems:
b <- 6
b < -6
So maybe
==  can become =
=  can become :=
(This reminds me Pascal syntax.)


In time, Python seems to become more similar to the Mathematica (and
in IPython this is even explicit) ^_^

Bear hugs,
(Remove HUGS to mail me)



More information about the Python-list mailing list