Bragging about Python
Mathias Panzenboeck
e0427417 at student.tuwien.ac.at
Thu Jun 7 10:21:01 EDT 2007
Steve Howell schrieb:
> --- "pinkfloydhomer at gmail.com"
> <pinkfloydhomer at gmail.com> wrote:
>
>> Is there a resource somewhere on the net that can be
>> used to quickly
>> and effectively show Python's strengths to
>> non-Python programmers?
>> Small examples that will make them go "Wow, that
>> _is_ neat"?
>>
>
> 15 small programs here:
>
> http://wiki.python.org/moin/SimplePrograms
>
IMHO a few python goodies are missing there.
e.g. generator functions:
# generic fibonacci without upper bound:
def fib():
parent_rabbits, baby_rabbits = 1, 1
while True:
yield baby_rabbits
parent_rabbits, baby_rabbits = baby_rabbits, parent_rabbits + baby_rabbits
# only calculate and print the first 100 fibonacci numbers:
from itertools import islice
for baby_rabbits in islice(fib(),100):
print 'This generation has %d rabbits' % baby_rabbits
More information about the Python-list
mailing list