Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Erik Newsgroups: comp.lang.python Subject: Re: List of Functions Date: Mon, 28 Mar 2016 00:10:01 +0100 Lines: 32 Message-ID: References: <3c44f0f8-d701-463e-bf2c-f5871c51bddf@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de kNHszxJUy0Pne8Erx/wtlQh5aD2RaKDECy4h016nuqOg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; '[0]': 0.07; 'buttons': 0.09; 'positional': 0.09; 'python': 0.10; 'def': 0.13; '(people': 0.16; 'from:addr:python': 0.16; 'nudge': 0.16; 'pep8': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'url:pep-0008': 0.16; 'wrote:': 0.16; 'to:2**1': 0.21; 'number)': 0.22; 'referring': 0.22; 'code.': 0.23; 'bit': 0.23; 'seems': 0.23; 'header:In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'define': 0.27; 'question': 0.27; 'about.': 0.29; 'url:peps': 0.29; 'whitespace': 0.29; "i'm": 0.30; 'print': 0.30; 'relative': 0.30; '[1]': 0.32; 'realize': 0.32; 'useful': 0.33; 'url:python': 0.33; 'subject:List': 0.33; 'list': 0.34; 'url:dev': 0.35; 'but': 0.36; 'url:org': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'thanks': 0.37; 'does': 0.39; 'received:192': 0.39; 'to:addr:python.org': 0.40; 'your': 0.60; 'charset:windows-1252': 0.62; 'sharing': 0.64; 'friendly': 0.74; 'br,': 0.84 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=O6PEx0JW c=1 sm=1 tr=0 a=BtX40c5qGHjBwFgnk142hQ==:117 a=BtX40c5qGHjBwFgnk142hQ==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=N659UExz7-8A:10 a=8AHkEIZyAAAA:8 a=fZ0XAs2bHXPXhSEYUL4A:9 a=XK6qnPFKDMjq5IE4:21 a=sx_6FU5UHyIZRYZb:21 a=pILNOxqGKmIA:10 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 In-Reply-To: <3c44f0f8-d701-463e-bf2c-f5871c51bddf@googlegroups.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:105879 Hi Richard, On 27/03/16 20:38, Richard Riehle wrote: > I realize that this seems trivial to many experience Pythonistas. But it might prove useful for those who are relative newcomers Thanks for sharing your solution (people finding the original question because it happens to match their own may then find this follow-up). However, please also read PEP8 - https://www.python.org/dev/peps/pep-0008/ >>>> def button1(number): > print ('button1 = ', number) ## define the buttons >>>> def button2(number): > print ('button2 = ', number) >>>> def button3(number): > print ('button3 = ', number) >>>> buttonList = [button1, button2, button3] ## create the list >>>> >>>> buttonList [1] (25) ## using positional association > button2 = 25 >>>> buttonList [0] (number = 78) ## using named association > button1 = 78 > The whitespace before the [] and () is what I'm referring you to PEP8 about. Of course, you can do what you want - this is just a friendly nudge ;) That extra whitespace does make it a bit harder to grok if you're used to reading "typical" Python code. BR, E.