Three dumb questions (ordered by dumbness descending)
Carl Banks
imbosol at vt.edu
Mon Sep 23 23:38:44 EDT 2002
Steven Feil wrote:
> On Mon, 23 Sep 2002 16:03:21 -0500, Thorsten Kampe wrote:
>
>> Okay, here they are:
>
> Ok, I'll take a stab at the first two questions. I do think that a
> little more clarity on your part could make it a bit easer.
>
> The first thing to remember is that Python is a dynamically typed
> language. It is typed and each object has a type, It would be a little
> easer if you would disclose the type for each object you are referring
> to.
>
>
>> 1. Why is 'zip(zip(x)) != x' (should be the same because it's the
>> transposed)
>
[snip]
>
> I will need to know more about where you got zip from.
It's a builtin, since Python 2.0. Very handy for when you want to
loop over two sequences side-by-side. For example:
for x,i in zip(seq,range(len(seq)):
print "Item %d of seq is %s" % (i,x)
>> 2. Peter Norvig mentions in "Python for Lisp Programmers" some
>> "don'ts": "[x] + y" and "x[1:]". Are there more things to avoid
>
> humm, "[x] + y", again it comes down to type.
[snip]
In this case, the types of x and y are obvious to someone familiar
with functional programming. Yet I wonder what the point of these
"don'ts" is.
I imagine he means that adding and slicing lists is Python is not as
efficient as it is in LISP? I wonder, then, what the recommended way
do functional stuff like that.
--
CARL BANKS
http://www.aerojockey.com
More information about the Python-list
mailing list