[python-advocacy] How programming language webpages should be designed
Roy Smith
roy at panix.com
Thu Nov 12 19:22:13 CET 2009
Yikes! That looks more like an entry for an Obfuscated Python contest
than something we want to put on the home page as an example of how simple
and appealing Python is.
> On Thu, Nov 12, 2009 at 4:59 PM, Michael Tobis <mtobis at gmail.com> wrote:
>> OK, now we need to decide whether the code is aimed at beginners
>> rather than professionals.
>>
>> I am fond of this trick as a python demo:
>>
>> ####
>>
>> # pythagorean triples
>>
>> def triples(upto=100):
>> R = lambda N : range(1,N+1)
>> for triple in [
>> (x, y, z) for z in R(upto) for y in R(z) for x in R(y)
>> if x*x + y*y == z*z]:
>> print triple
>>
>> triples()
>>
>> ####
>>
>> Exercises: 1) write it as a one-liner 2) eliminate redundant triples
>> like (6,8,10) which is really the (3,4,5) triple repeated 3) make it
>> go faster (it's O(N^3); not difficult to make it O(N^2))
>>
>> This is an elementary exercise (no imports) that shows off some less
>> mundane features of Python.
>>
>> Showing off SimpleHTTPServer is also a good idea to demonstrate the
>> ideas of included batteries.
>>
>> I like Dave's idea of a Twitter client. Recursive puzzles, like
>> Sudoko or 8 queens...
>>
>> We need to come up with examples where the objective is easy to
>> understand and where python is extraordinary, at least compared to
>> what they are probably already using.
>>
>
> (replying on-list, I've figured out you missed the reply-all)
>
> Maybe a random script can be displayed when the page is displayed, so
> we can have several snippets ?
>
> Tarek
> _______________________________________________
> Advocacy mailing list
> Advocacy at python.org
> http://mail.python.org/mailman/listinfo/advocacy
>
>
More information about the Advocacy
mailing list