Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: 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; 'win32': 0.03; 'languages,': 0.04; 'c++,': 0.07; 'column': 0.07; 'arguments': 0.09; 'instance.': 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; 'api': 0.11; '(x,': 0.16; '>in': 0.16; 'behave': 0.16; 'message-id:@4ax.com': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'spreadsheet.': 0.16; 'extensions': 0.16; 'bit': 0.19; 'comfortable': 0.22; 'creating': 0.23; 'load': 0.23; 'button,': 0.24; 'url:home': 0.24; "i've": 0.25; 'excel': 0.26; 'values': 0.27; 'header:X-Complaints-To:1': 0.27; 'function': 0.29; 'external': 0.29; 'array': 0.29; 'code': 0.31; 'run': 0.32; 'fri,': 0.33; 'table': 0.34; "i'd": 0.34; 'problem': 0.35; 'but': 0.35; 'done': 0.36; 'charset:us-ascii': 0.36; 'example,': 0.37; 'two': 0.37; 'challenging': 0.38; 'nov': 0.38; 'richard': 0.38; 'to:addr:python-list': 0.38; 'functional': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'office,': 0.64; 'results': 0.69; 'felt': 0.74; 'spreadsheet': 0.84; 'family.': 0.91; 'ports': 0.93; 'received:108': 0.93; 'tied': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: Array of Functions Date: Fri, 14 Nov 2014 19:13:15 -0500 Organization: IISS Elusive Unicorn References: <42b534f0-aeef-411f-80c5-db5d20c80b55@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: adsl-108-79-216-34.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 6.00/32.1186 X-No-Archive: YES X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 33 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1416010397 news.xs4all.nl 2929 [2001:888:2000:d::a6]:42168 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:80796 On Fri, 14 Nov 2014 14:17:23 -0800 (PST), Richard Riehle declaimed the following: >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. I am finding this a bit challenging in Python. > >Example: > > r1c1 r1c2 r1c3 > r2c1 r2c2 r2c3 > r3c1 r3c2 r3c3 > Personally (and tied to Windows) -- I'd likely load the win32 extensions package and, since I do have M$ Office, programmatically create that spreadsheet in a hidden Excel instance. Caveat: I've never actually done that... M$'s API has never felt comfortable to me (I was spoiled by ARexx and applications with ARexx ports on the Amiga). I don't know of any way to "magically" link your column three to using arguments from the other two columns. Creating a table where each row is two values and a function is no problem -- but I'd need to use external code to run each row: results = [ f(x, y) for (x, y, f) in table] -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/