Can global variable be passed into Python function?

Mark H. Harris harrismh777 at gmail.com
Fri Feb 28 23:36:25 EST 2014


On Friday, February 28, 2014 8:15:38 PM UTC-6, Ned Batchelder wrote:

> Mark, if you are going to advocate for a feature, find a good use case, 
> this one is absurd.  Where did the constants GT_1 etc, come from?

Not at all.   Think of the C switch block... if you read about it in the K & R you'll think its useless...  because it can only switch on a SINGLE character. So, to make it work what do you do???  You create some constants that are actually really and totally just a number... one character... that represents  GT_1  or anything else.

The switch block "switches" on a character in C.   In python it could switch on absolutely anything we like... the point is not how it switches... but how it "looks" to human beings, and "maybe" how it performs. 

For me its more important that code be readable first and foremost... then optimized.   Yes, I can use if elif else   blocks and I can and do use dict dispatch tables.... but I "wish" there were a switch case default block in python so that some things could be coded to be clearer to a human reader.

just sayin...   not arguing though...   just a comment.



More information about the Python-list mailing list