You are viewing a plain text version of this content. The canonical link for it is here.
Posted to community@apache.org by Greg Stein <gs...@lyra.org> on 2003/01/09 23:09:50 UTC

python foo (was: email notification done...sorta)

On Thu, Jan 09, 2003 at 08:42:58AM -0800, Stefano Mazzocchi wrote:
> David N. Welton wrote:
>...
> > Anyone can code in Python.  It's easy, and it runs anywhere.  Not
> > quite an offer of help, but... if you have figured out one programming
> > language, picking up Python will not be hard, nor unpleasant.
> 
> That's been my experience... but python really needs better support for 
> multidimensional arrays :-) or merge numeric python in the default 
> language. But anyway...

Huh?

>>> array = [ [1, 2, 3],
...           [4, 5, 6],
...           [7, 8, 9] ]
>>> print array[1][2]
6
>>> sparse = { (1,2): 6, (2,1): 8 }
>>> sparse[1,2]
6
>>>

The Numeric package is for high-performance numeric computation. Most users
don't need that kind of heavy-lifting. There are also some semantic oddities
in the package that need to be ironed about before it could move into the
core Python distribution.

But out of the box? Python has multidimensional arrays. Not sure what you're
smoking :-)

(and don't ask me about the time I tried to do a hash of hashes of hashes in
 Perl... even with Perl hacker help, I gave up; Perl just wouldn't do it)

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/

Re: python foo

Posted by Rich Bowen <rb...@rcbowen.com>.
On Fri, 10 Jan 2003, Greg Stein wrote:

> > $matrix = [
> >            [1, 2, 3],
> >            [4, 5, 6],
> >            [7, 8, 9] ];
> > print $matrix->[1][2];
>
> Very cool. Man, I wish that woulda worked when I tried it.
>
> > A little more punctuation, but, then, you'd expect that from Perl.
> >
> > You must have a very lame Perl hacker at your disposal. ;-)
>
> This was sometime around 1996, I believe. Perl 4, if I recall. Is it
> possible that it wasn't so easy in Perl 4?

Ah. No. Not possible in Perl 4. That was back in the dark ages! ;-) I
guess I did not realize that Python was already around back then.
References (aka pointers, only not) appeared in Perl 5, and are what
makes this syntax posibble.

-- 
Nothing is perfekt. Certainly not me.
Success to failure. Just a matter of degrees.


fu

Posted by Ben Hyde <bh...@pobox.com>.
>>
>>> ... Perl ...
>> ... Python ...
>>

I can't say as I recall one of these my-language/your-language 
discussions ending well at any point in the last 35 years.  It's very 
close to arguing if my life philosophy is better than yours.  I think 
it might be better, if people want to go down that path, to broaden the 
discussion into one closer to comparative religion.

I very much enjoyed, and still do, in depth comparative language study. 
  When the computer science community was much less tightly connected - 
so that the opportunities for network effects were much weaker - there 
were dozens and dozens of really fascinating programming languages 
micro-lanaguages for specific domains.

Some of my favorites...

SETL (NY University) was pretty amazing.  It pretty much only had hash 
tables.  After a while they managed to get's compiler so elegant that 
it started to automatically optimize programs into algorithms that a 
few years before had seemed to be serious inventions - for example it 
could discover spanning tree based algorithms.  As far as I know this 
branch of elegance has died out.  There was a very amusing moment when 
the SETL folks wrote an Ada compiler years before anybody else managed 
to get one written.

Simula ( which was cira 1968, had all the modern tools for writing 
object oriented multi-threaded programs.  Almost all the neat ideas in 
Simula were reinvented every 2-3 years till today.  This tradition is 
probably still alive in ELang (which takes a light dose of Prolog-fu as 
well).  I can't too highly recommend a study of the ELang light-wieght 
threading model to people working on distributed systems.

The SNOBOL .. ICON (University of Arizona) had some very nice ideas 
about how to manage the control stack of a program to get search, 
iteration, pattern-matching.  There was a very interesting language in 
this line that broke the act of calling a function into it's component 
parts (binding, dispatching, returning etc.) and then managed to let 
you compose those to create iteration generators etc.

I enjoyed working on a number of graphic layout languages.  DOT is one 
of the modern examples.

I bet some other people here know of some sweet historical examples.

Etc. etc. etc.


Re: python foo

Posted by Greg Stein <gs...@lyra.org>.
On Thu, Jan 09, 2003 at 05:39:42PM -0500, Rich Bowen wrote:
>...
> > (and don't ask me about the time I tried to do a hash of hashes of hashes in
> >  Perl... even with Perl hacker help, I gave up; Perl just wouldn't do it)
> 
> Oh, come on. I do hashes of hashes of hashes frequently in Perl. And
> hashes of hashes of arrays of hashes of arrays. And ... well, other
> permutations.

Sure, I know it is possible, but really. At the time, it just didn't work.
Really. Not some kind of lamer-fu.

> And the syntax for a multi-dimensional array is almost
> indistinguishable from the example you gave in Python.
> 
> $matrix = [
>            [1, 2, 3],
>            [4, 5, 6],
>            [7, 8, 9] ];
> print $matrix->[1][2];

Very cool. Man, I wish that woulda worked when I tried it.

> A little more punctuation, but, then, you'd expect that from Perl.
> 
> You must have a very lame Perl hacker at your disposal. ;-)

This was sometime around 1996, I believe. Perl 4, if I recall. Is it
possible that it wasn't so easy in Perl 4?

And yah... if the two guys that I was getting help from didn't get it, then
I'd be surprised (I respect the guys, quite a bit)

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/

Re: python foo (was: email notification done...sorta)

Posted by Stefano Mazzocchi <st...@apache.org>.
Greg Stein wrote:

> But out of the box? Python has multidimensional arrays. Not sure what you're
> smoking :-)

I said *better* support. I didn't say that Python doesn't support them. 
The creation and manipulation of multidimensional arrays was the only 
thing I found to be cumbersome and harder than in java, until I found 
Numberic Python which does have a bunch of API that help you a lot with 
those. But at the end, I was able to go around the problem myself. Just 
took a while. In fact, there are a couple of requests for enhancements 
on python.org exactly about this so I assume I'm not the only one who 
had this problem.

Ah, btw, yes, I'm not sure about what I have been smoking either :)

-- 
Stefano Mazzocchi                               <st...@apache.org>
--------------------------------------------------------------------



Re: python foo (was: email notification done...sorta)

Posted by Rich Bowen <rb...@rcbowen.com>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thu, 9 Jan 2003, Greg Stein wrote:

> >>> array = [ [1, 2, 3],
> ...           [4, 5, 6],
> ...           [7, 8, 9] ]
> >>> print array[1][2]
> 6
> >>> sparse = { (1,2): 6, (2,1): 8 }
> >>> sparse[1,2]
> 6
> >>>
>
> (and don't ask me about the time I tried to do a hash of hashes of hashes in
>  Perl... even with Perl hacker help, I gave up; Perl just wouldn't do it)

Oh, come on. I do hashes of hashes of hashes frequently in Perl. And
hashes of hashes of arrays of hashes of arrays. And ... well, other
permutations.

And the syntax for a multi-dimensional array is almost
indistinguishable from the example you gave in Python.

$matrix = [
           [1, 2, 3],
           [4, 5, 6],
           [7, 8, 9] ];
print $matrix->[1][2];

A little more punctuation, but, then, you'd expect that from Perl.

You must have a very lame Perl hacker at your disposal. ;-)

- -- 
Oh I have slipped the surly bonds of earth
And danced the sky on laughter-silvered wings
 --High Flight (John Gillespie Magee)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
Comment: Made with pgp4pine 1.75-6

iD8DBQE+Hfo0XP03+sx4yJMRAsL8AJ49DT5Hxwftqja8L3w6VW12J5UTbwCg04m5
YOCMTjXkAMpPfIR5WYS29Ac=
=IeC3
-----END PGP SIGNATURE-----