Ka-Ping Yee wrote:

Can you explain what you meant by currying here?  I know what
the word "curry" means, but i am having a hard time seeing how
it applies to your example.

It's currying in the sense that instead of one function which takes all the args at once, you have a function that takes some of them (all except the thunk) and returns another one that takes the rest (the thunk).

Could you make up an example that uses more arguments?

def with_file(filename, mode): def func(block): f = open(filename, mode) try: block(f) finally: f.close() return func

Usage example:

  with_file("foo.txt", "w") as f:
    f.write("My hovercraft is full of parrots.")

Does that help?

--
Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,          | A citizen of NewZealandCorp, a       |
Christchurch, New Zealand          | wholly-owned subsidiary of USA Inc.  |
[EMAIL PROTECTED]          +--------------------------------------+
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to