very good reasons?

Grant Griffin g2 at seebelow.org
Sun Oct 1 16:05:38 EDT 2000


Kragen Sitaker wrote:
> 
> In article <8r2k0n01u30 at drn.newsguy.com>,
> Grant Griffin  <g2 at seebelow.org> wrote:
> >I was trying to chain "sort" and "reverse" together the other day <<confess>>,
> >ala Perl, but I found that it didn't work . . .
> >I would have expected sort and reverse to return the list in question, but
> >instead they return None.  So I had to do something like:
> 
> If you want Perl, you know where to find it: in Python!  Here's how:
> 
> def sort(x):
>         y = list(x)
>         y.sort()
>         return y
> 
> def reverse(x):
>         y = list(x)
>         y.reverse()
>         return y
> 
> >>> y
> [1, 2, 17, 4, 5]
> >>> reverse(sort(y))
> [17, 5, 4, 2, 1]

Good point!  (I guess there's _always_ "more than one way to do it" in
programming languages. ;-)

> The Python way is probably clearer and more efficient, though.
> 
> >Likewise, I wondered the other day why "real" and "imag" are "attributes" of
> >complex numbers instead of functions: [but you can't set them]
> 
> Complex numbers are immutable.  Dunno why.  Maybe so they're like other
> numbers.

I guess from that perspective, I would have expected "real" and "imag"
to be "member" functions: x.real(), x.imag().  (Or am I still thinking
too much like C++?)

> By the way, what's a Iowegian, and how do you pronounce it?

It's an affectionate term (sortta ;-) for someone who lives in the state
of Iowa, USA.  (See http://www.slanguage.com/minneapolis.html.)

If "Iowegian" were a vanity plate, it would be pronounced something
like:

	IOWEJN

(Rhymes with "Norwegian".)

I grew up in Missouri, and now I live in Kansas, but I lived in Iowa for
a long time: it was really nice.

people-think-the-only-thing-in-iowa-is-corn,-but-they-also-have
   -beans-(soybeans),-pigs,-a-very-nice-little-symphony-orchestra,
   -and-a-radio-factory-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