python gripes survey

Andrew Dalke adalke at mindspring.com
Sun Aug 24 14:01:19 EDT 2003


Ryan Lowe:
> > >>> d = {1: "a"}
> > >>> d.update({True: "b"})
> > >>> d
> > {1: 'b'}
>
> that is weird; i thought 2.3 made bool its own type? but i guess its still
a
> subtype of int. though, i cant imagine when this would come up in a real
> situation anyway.

Let k1 and k2 be two keys.  If k1==k2 then dicts consider that
either one may be used as the key.  Since 1 exists in d, and 1 == True
(== 1.0, == complex(1,0)) then the update keeps the old key rather
than do the extra work of replacing it.

It isn't quite this easy.  k1 and k2 must also have aligned hashs,
which is used to prune the number of == tests done.

> >   code blocks (like Smalltalk)
>
> is this what it sounds like? do you name a block of code and call it like
an
> inline function with no parameters?

Consider the following Ruby code

 [ 1, 3, 5 ].each { |i| puts i }

The
  |i| puts i
 is an *unnamed* code block which does take parameters.
The [] is a container, and [].each sends the code block to
each of the elements in the container.  See
  http://www.rubycentral.com/book/tut_containers.html

> i learned and forgot what lazy evaluation was. does it buy you anything
> other than speed in certain cases

Sometimes it's easier to work with infinite sets directly
rather than work on iterators going through infinite sets.
Eg, suppose you wanted the first 5 primes which were
fibonacci sequences.  Then you can do something like

  (primes && fibonacci)[:5]

> >   rich N-dimensional operators (like APL)
>
> python could do the same with functions or named operators

Sure.  But they aren't built-in, and there is something
cool about using non-ASCII symbols in your code.
(As someone with a now-dusty math degree, I am
pretty used to glyphs like greek letters in my work.)

> >   symbolic math manipulation (like Mathematica)
>
> this is approaching the limited domain area. plus mathematica spent a LOT
of
> money and time writing that software. its not something your average
> open-sourcer would probably wish to tackle in their spare time. of course,
> it would be nice to have a symbolic module :)

Agreed for the first.  The point remains that it is something
which Python doesn't have.  It could be added as modules, but
Mathematica's syntax makes it easier to express some equations
than Python does.

> >   color as part of syntax (like ColorForth)
>
> color meaning built-in? this i have never heard of. how does it work?

Google.  "color forth".  "I'm feeling lucky"
  http://www.colorforth.com/
] In Forth, a new word is defined by a preceeding colon, words inside
] a definition are compiled, outside are executed. In colorForth a new
] word is red, green words are compiled, yellow executed. This use of
] color further reduces the syntax, or punctuation, needed. It also makes
] explicit how the computer will interpret each word.


> >   predicate logic (like Prolog)
> >   literate programming (like WEB -> Pascal/TeX)
> >   aspect-oriented programming (like AspectJ)
> >   stack nature (like Postscript (I had Forth here but didn't want a dup
> :))
> >   programming by contract (like Eiffel)
>
> can any of these be explained quickly?

Google.  "predicate logic" prolog.  "I'm feeling lucky"
 http://remus.rutgers.edu/cs314/f2002/uli/lectures/lec24.pdf

Google.  "literate programming" web.  "I'm feeling lucky"
http://www.literateprogramming.com/

Google. "aspect-oriented programming".  "I'm feeling lucky"
http://aosd.net/

Google. "FORTH".  "I'm feeling lucky".  Browse a few links
to the FAQ
ftp://ftp.forth.org/pub/Forth/FAQ/general

Here's another route.  Go to FOLDOC ("Free on-line dictionary
of computing").  Search for "FORTH"
] 1. <language> An interactive extensible language using postfix
] syntax and a data stack, developed by Charles H. Moore in
] the 1960s.

Follow the link for "postfix notation"
 http://wombat.doc.ic.ac.uk/foldoc/foldoc.cgi?postfix+syntax

"Programming by contract" should be "Design by contract".
In addition to Google for these searches, try the PPR wiki,
eg http://c2.com/cgi/wiki?DesignByContract

                    Andrew
                    dalke at dalkescientific.com






More information about the Python-list mailing list