List of Functions

Erik python at lucidity.plus.com
Sun Mar 27 19:10:01 EDT 2016


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.



More information about the Python-list mailing list