Python functional "Hello" meme

Published at 26, November 2008, author art. Tags: fun, functional, python

This is another interpretation of Eric's task. This time in functional way, python incarnation.

import itertools, sys 
[sys.stdout.write('%s) Hello, %s\n' % tuple(reversed(item))) \
    for item in itertools.izip(
        itertools.repeat(raw_input('Please enter your name: ')),
        xrange(int(raw_input('Please enter your age: '))))]

Pingbacks

permalink

18, November 2009, pingback from http://dwins.wordpress.com/2009/11/18...:

[Functional Python] http://aartemenko.com/texts/python-functional-hello-meme/

Comments

Subscribe on this post's comments

permalink

26, November 2008, owner of http://tilarids.blogspot.com/ said:

  1. Use izip
  2. I suggest you to add 'and True' into the end of expression

permalink

26, November 2008, art said:

I know about izip, but leave 'zip' in favour of simplicity.

permalink

27, November 2008, ericflo said:

Haha, this is a two-liner! That's awesome.

permalink

27, November 2008, art said:

Actually, you could write: import itertools, sys; blah blah blah in one line.

If you wish to leave comment, please, identify yourself and then come back to this page.