python idioms: (was: a really cool python feature)

Grant Griffin g2 at seebelow.org
Sat May 13 00:06:08 CEST 2000


Neil Schemenauer wrote:
> 
> Grant Griffin <g2 at seebelow.org> wrote:
> >Forgive a possible newbie FAQ, but is there a page of Python
> >idoms like this?
> 
> Python doesn't have too many idoms and that's a good thing.
> string.join is not an idom. That function is for exactly that
> usage. 

I guess by "idiom" I was thinking of "recurring little bits of code to
do common operations, that experienced people know".  In that sense this
is an idiom, if also a library function.  ("It's a floor wax?/It's a
desert topping/No, it's both!)

> The only problem would be finding it in the library
> reference.

Exactly.  As a Python newbie, I am repeatedly faced with this problem. 
I'm finding that although the syntax of Python can be learned in a
pretty short time, learning the library remains a big effort.  (But it's
a complex thing, so I guess there's no way around that.)

> The only really useful idioms I can think of right now are:
<good stuff snipped-thanks; thanks also to Tom Loredo for link to useful
python 'phrases'>

One gizmo I've frequently needed (which I dug out of Deja awhile back)
is to print a dictionary sorted by its values.

if-ronco-sold-idioms-i-bet-they'd-call-it-"the-idiomatic"-<wink>
  -ly y'rs,

=g2
-- 
_____________________________________________________________________

Grant R. Griffin                                       g2 at dspguru.com
Publisher of dspGuru                           http://www.dspguru.com
Iowegian International Corporation	      http://www.iowegian.com



More information about the Python-list mailing list