Some more notes

bearophile bearophileHUGS at lycos.com
Thu Oct 21 18:16:31 EDT 2004


Ville Vainio:
>It's highly typical for the newbies to suggest improvements to the
>language. They will usually learn that they are wrong, but the
>discussion that ensues can be fruitfull anyway :-).

Few more notes on the language. I don't know if I can really suggest
improvements to the language... but I hope to learn something :-)

I think some things are better in Delphi/Pascal (like the := for
assignments instead of = and = for equality, that I suggested in the
my precedent notes):

1) The "print" and "printf" pair without automatically added spaces
between arguments, and with or without automatic newline, instead of
the current "print" command. Because adding lots of "+str()+" isn't
good for me (there's sys.stdout.write, but it's not built-in).
2) Adding "case var of:" can be useful.
3) "do while" (or "repeat until") can also be added, it's useful.
4) Maybe really raw strings RR"" can be added to avoid problems with
file paths on Win :-]

5) Inside function definitions, assignments of mutable types like this
can be forbidden and seen as errors by the interpreter:
def func(a=[1,2]):
    ...

6) Given:
a = [1]
a += [2]
a = a + [3]
The first assignment extends the list, and second creates a new list
and rebinds it. Why such difference for operations that look the same?
Isn't a kind of "error" to do different things with quite similar
looking commands?

7) There's something that I don't understand. I'm not a OOP purist,
but finding functions like this beside normal methods seems odd to me:
len(s) length of s
min(s) smallest item of s
max(s) largest item of s
For uniformity they can be:
s.len()
s.min()
s.max()
etc.

Thank you,
bear hugs,
Bearophile



More information about the Python-list mailing list