Advice from Jeff (Was Re: Is there "let binding" in Python?)

Don Bruder dakidd at sonic.net
Mon Sep 15 13:58:42 EDT 2003


In article <YJGdnbh7jKtyS_iiU-KYvA at comcast.com>,
 "Terry Reedy" <tjreedy at udel.edu> wrote:

> "Don Bruder" <dakidd at sonic.net> wrote in message
> news:o0d9b.21665$dk4.674856 at typhoon.sonic.net...
> > In article <mailman.1063592122.17998.python-list at python.org>,
> >  Jeff Epler <jepler at unpythonic.net> wrote:
> > > Not an answer, but advice: when writing programs in Python,
> >> write Python programs.
> >
> > Gawd, but that's profound! And on several levels... No... I'm
> serious.
> > But I'm also smiling.
> 
> Jeff's advice is perhaps too terse for someone not already familiar
> with it.  Does the following seem more helpful?
> 
> If you are writing a Python program to either learn Python or
> accomplish a computing task, you will probably be happier and more
> successful (in the middle to long run) if you write idiomatic Python
> rather than 'literal translations' in the style of some other langauge
> and *its* idioms.
> 
> The OP is not the first to more or less ask 'how do I literally
> translate this foreign idiom' (which the poster may not even see as a
> language-specific idiom) rather than 'how do I accomplish the same
> function'.  This questions usually garner the advice given above.

Like I said, that's *VERY* profound advice. It wasn't a question of me 
"not understanding", it was an observation of fact. Even if it does make 
me grin when I read it.
  
> > >  If it's your task to translate some Scheme (or any other
> > > language) into Python as literally as possible, my heart goes out
> to you.
> 
> > How miserable do you expect me to be translating from
> > Python to C/C++ as literally as possible?
> 
> In respect to the basic data/object model, Python is more similar to
> Lisp than C++.  In respect to syntax, the opposite is true.

I have (mercifully) forgotten almost all of the tiny bit of lisp I ever 
knew. Never before or since have I seen such a butt-ugly, unfreindly, 
difficult to deal with language. On second thought, I take that back... 
Brainf*ck may be the only contender.

> By default, Python code is generic -- it runs with any object with the
> needed interface.  So, unless a block is explicitly specialized to one
> type with a preceeding assert or conditional, the literally 'as
> literal as possible' translation to C++ is to template code.  Are you
> doing this, or specializing  the C++ code by declaring variables and
> function parameters to a particular type?

Definitely declaring variables. I'm nowhere near far enough along to 
mess with templates yet. They just confuse me.

-- 
Don Bruder -  dakidd at sonic.net <--- Preferred Email - SpamAssassinated.
Hate SPAM? See <http://www.spamassassin.org> for some seriously great info.
I will choose a path that's clear: I will choose Free Will! - N. Peart
Fly trap info pages: <http://www.sonic.net/~dakidd/Horses/FlyTrap/index.html>




More information about the Python-list mailing list