Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #80794

Re: Array of Functions

Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'languages,': 0.04; 'interpreter': 0.05; 'c++,': 0.07; 'expressions': 0.07; "'python": 0.09; 'exec': 0.09; 'executes': 0.09; 'grid': 0.09; 'objects,': 0.09; 'pointers': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'runtime': 0.09; 'url:github': 0.09; 'runs': 0.10; 'python': 0.11; 'def': 0.12; 'jan': 0.12; 'programs.': 0.14; 'behave': 0.16; 'expects': 0.16; 'expression,': 0.16; 'googling': 0.16; 'objects.': 0.16; 'quoted': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'repl': 0.16; 'spreadsheet.': 0.16; 'language': 0.16; 'wrote:': 0.18; '(not': 0.18; 'bit': 0.19; 'fit': 0.20; 'header:User-Agent:1': 0.23; 'button,': 0.24; 'values': 0.27; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'array': 0.29; 'related': 0.29; 'mode': 0.30; 'nature': 0.30; 'code': 0.31; 'easier': 0.31; 'this.': 0.32; 'run': 0.32; 'but': 0.35; 'there': 0.35; 'functions.': 0.36; 'example,': 0.37; 'challenging': 0.38; 'richard': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'functional': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'even': 0.60; 'easy': 0.60; 'first': 0.61; 'difficulty': 0.68; 'parser,': 0.84; 'received:fios.verizon.net': 0.84; 'family.': 0.91; 'received:108': 0.93
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Terry Reedy <tjreedy@udel.edu>
Subject Re: Array of Functions
Date Fri, 14 Nov 2014 19:11:34 -0500
References <42b534f0-aeef-411f-80c5-db5d20c80b55@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host pool-108-16-203-145.phlapa.fios.verizon.net
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0
In-Reply-To <42b534f0-aeef-411f-80c5-db5d20c80b55@googlegroups.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.15834.1416010316.18130.python-list@python.org> (permalink)
Lines 35
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1416010316 news.xs4all.nl 2864 [2001:888:2000:d::a6]:40590
X-Complaints-To abuse@xs4all.nl
Path csiph.com!usenet.pasdenom.info!bete-des-vosges.org!feed.ac-versailles.fr!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Xref csiph.com comp.lang.python:80794

Show key headers only | View raw


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


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