[Python-Dev] complaints..

Georg Brandl g.brandl at gmx.net
Sun Jan 13 18:28:31 CET 2008


Jay schrieb:

Only addressing the easier points here:

> #----------------------------------------------------------
> # flaw #2
> #
> # In functions, reads are scoped. Writes are not.
> #
> 
> A = "1"
> 
> def F1():
>     A = "2" # not an error
> 
> def F2():
>     #B = A # error
>     A = "3"
>     
> F1()
> F2()
> print(A)

"Writes" creates a new local. If you want to modify the enclosing
binding, the new "nonlocal" statement in 2.6/3.0 will enable that.

> #----------------------------------------------------------
> # flaw #3:
> #  lambda is neutered
> #  It allows just one expression, and no statements

Lambda can't be altered to allow statements *and* have a consistent
indentation-based syntax.

> #----------------------------------------------------------
> # flaw #5
> #
> # for loops suck
> #
> # It should be easy to iterate from 0 to n, not 0 to n - 1,
> # thereby knowing why the loop terminated
> #
> 
> #This should work:
> 
> # print the first even number, if there are any
> 
> A = [1, 3]
> for i in range(0, len(A)):
>     if ((A[i] % 2) == 0):
>         print("even number found")
>         break;
> if (i == len(A)):
>     print("no even numbers found")

The for loop has an else clause.

for x in A:
     if x % 2 == 0:
         print "even number found"
         break
else:
     print "no even numbers found"

> Flaw #6
> 
> The docs are very good.
> 
> However the reference doesn't give much in the way
> of semantic description.
> 
> It is surprising that an experienced programmer MUST
> depend on the tutorial or any examples or semantics.
> Light on examples, ok for reference.
> 
> The language reference is little more than the grammar in parts.
> 
> There needs to be links from the reference back to the tutorial.
> 
> Perhaps merge the indices for Tutorial, Language Reference, Library 
> Reference.
> Or maybe that's what search is for.

Look at the new docs for 2.6 -- there's many more references in it.
http://docs.python.org/dev

> #----------------------------------------------------------
> # Flaw #7
> #
> # This is a compatibility issue.
> # print is both a statement and a function, or something..
> #
> 
> print() # should print just a newline, but prints two parens
> 
> # workaround:
> 
> print("")

print is a statement, and no function. () is an empty tuple, so
"print ()" prints an empty tuple.
(""), on the other hand, is the same as "".

> #----------------------------------------------------------
> # flaw #8
> #
> # Having to eval expressions but exec statements feels wrong.
> # There should just be eval.
> #
> 
> # eval("print(1)") # error
> exec("print(1)") # not an error
> 
> exec("1 + 2") # not an error?
> eval("1 + 2") # not an error

There's a clear distinction between expressions and statements,
so it makes sense here too.

cheers,
Georg

-- 
Thus spake the Lord: Thou shalt indent with four spaces. No more, no less.
Four shall be the number of spaces thou shalt indent, and the number of thy
indenting shall be four. Eight shalt thou not indent, nor either indent thou
two, excepting that thou then proceed to four. Tabs are right out.



More information about the Python-Dev mailing list