Re: Python Online Programming Contest

2005-02-24 Thread Will Stuyvesant
> [Varun] > For details about samhita http://www.samhita.info/ "The Madras Institute of Technology (MIT)" it says there. The MIT acronym is taken already guys.. -- no scheme no glory -- http://mail.python.org/mailman/listinfo/python-list

Re: delay and force in Python

2005-01-24 Thread Will Stuyvesant
Just for the record, an implementation without using generators, somewhat like in Sect. 3.5 of the Wizard book, and without recursion limit problems. . . def stream_hd(s): # the head of the stream . return s[0] . . def stream_tl(s): # the tail of the stream . return s[1]() . . ## . # The lo

Funny Python error messages

2005-01-21 Thread Will Stuyvesant
Add your funny or surprising Python error messages to this thread. A requirement is that you should also show (minimal) code that produces the message. Put the code below, so people can think about how to generate the message first, a little puzzle if you like. Perhaps this will even be a usefu

Re: a question

2005-01-19 Thread Will Stuyvesant
Andrew Koenig wrote: > how about writing this instead? > > ('this is a ' > 'long string') Yes, nice. And to make that possible we have to write ('one-string-item',) instead of ('one-string-item') if we want a tuple with one string inside. Sometimes that feels like a wart to me, but now

Re: delay and force in Python

2005-01-19 Thread Will Stuyvesant
Yes you are right, if you just want to carry an expression around then lambda does it; but delay was not intended as a top-level function. Perhaps you think that my silly stream implementation in the original post builds the whole list, but it does not: >>> o = stream_enumerate_interval(11,121)

delay and force in Python

2005-01-19 Thread Will Stuyvesant
Here is a question for people who are more comfortable than I am with new Python stuff like generators. I am having fun implementing things from the Wizard book (Abelson, Sussman, "Structure and Interpretation of Computer Programs") in Python. In chapter 3.5 it is about streams as delayed lists.

Re: newbie q

2005-01-13 Thread Will Stuyvesant
mystring')) . .print add_string_to_all(['d:', 'c:\windows\\','something/']) this outputs: ['d:mystring', 'c:\\windows\\mystring', 'something/mystring'] -- look Ma, no for and no lambda! -- Will Stuyvesant -- http://mail.python.org/mailman/listinfo/python-list

Re: do you master list comprehensions?

2004-12-13 Thread Will Stuyvesant
Okay that was fun. Enlightening as I hoped. unroll() in Python, for arbitrary depth, _flatten in Tkinter (what else is in Tkinter!), sum() abuse. The sum(data,[]) was funniest, it works like ((['foo','bar'] + []) + ['my','your']) + ['holy','grail']. Before I think of such things I have already

do you master list comprehensions?

2004-12-13 Thread Will Stuyvesant
Here is a question about list comprehensions [lc]. The question is dumb because I can do without [lc]; but I am posing the question because I am curious. This: >>> data = [['foo','bar','baz'],['my','your'],['holy','grail']] >>> result = [] >>> for d in data: ... for w in d: ...result

Python compared with Xen (for XML)

2004-12-03 Thread Will Stuyvesant
Here is a comment on the paper "Programming with Circles, Triangles and Rectangles" by Erik Meijer, Wolfram Schulte and Gavin Bierman. Google will find it quickly if you try. In the paper they introduce Xen, an extension to C# for better XML support. They show how Lifting, Filtering and Apply-to