Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #80794
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Subject | Re: Array of Functions |
| Date | 2014-11-14 19:11 -0500 |
| References | <42b534f0-aeef-411f-80c5-db5d20c80b55@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.15834.1416010316.18130.python-list@python.org> (permalink) |
On 11/14/2014 5:17 PM, Richard Riehle wrote: > In C, C++, Ada, and functional languages, I can create an array of > functions, albeit with the nastiness of pointers in the C family. > For example, an array of functions where each function is an active > button, or an array of functions that behave like formulae in a > spreadsheet. Googling 'python spreadsheet', the first hit is https://manns.github.io/pyspread/ "Pyspread expects Python expressions in its grid cells," and expressions can reference other cells. There may be other relevant programs. > I am finding this a bit challenging in Python. Since python functions are objects, they easy fit into any array of objects. They can also be the values in dicts. Since strings can be passed to built-in runtime compile, eval, and exec functions, (not part of standard C), functions can also be represented by a return expression, as in Pyspread, or even quoted def statements. A program that executes user-entered code is much easier in Python than in C or any other language where one would have to write or find lexer, parser, compiler, and execution functions. > I think my difficulty is related to the REPL nature of Python. I do not understand this. The interpreter runs a REPL in interactive mode but can also run in batch mode. -- Terry Jan Reedy
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Array of Functions Richard Riehle <rriehle@itu.edu> - 2014-11-14 14:17 -0800
Re: Array of Functions Marko Rauhamaa <marko@pacujo.net> - 2014-11-15 00:21 +0200
Re: Array of Functions Sam Raker <sam.raker@gmail.com> - 2014-11-14 14:44 -0800
Re: Array of Functions Ian Kelly <ian.g.kelly@gmail.com> - 2014-11-14 15:50 -0700
Re: Array of Functions MRAB <python@mrabarnett.plus.com> - 2014-11-14 23:02 +0000
Re: Array of Functions Terry Reedy <tjreedy@udel.edu> - 2014-11-14 19:11 -0500
Re: Array of Functions Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-11-14 19:13 -0500
Re: Array of Functions Richard Riehle <rriehle@itu.edu> - 2014-11-16 23:52 -0800
Re: Array of Functions Anton <anschatten@gmail.com> - 2014-11-17 13:56 -0800
csiph-web