Can global variable be passed into Python function?

Chris Angelico rosuav at gmail.com
Fri Feb 28 00:53:35 EST 2014


On Fri, Feb 28, 2014 at 4:39 PM, Mark H. Harris <harrismh777 at gmail.com> wrote:
> On Thursday, February 27, 2014 10:43:23 PM UTC-6, Chris Angelico wrote:
>
>> Simple rule of thumb: Never use 'is' with strings or ints. They're
>> immutable, their identities should be their values. Playing with 'is'
>> will only confuse you, unless you're specifically going for
>> introspection and such.
>
> Right.  The only time I use "is"   is when I'm trying to explain to someone new to python assignment what is happening inside... what Mark Summerfield calls "python's beautiful heart," in his his recent book, "Programming in Python 3" ... a great resource, by the way.
>

'is' can and should be used with mutables, to distinguish between
identical values with different identities. It's also appropriate to
use 'is' with special singletons like None. Just be careful of ints
and strings.

ChrisA



More information about the Python-list mailing list