On Fri, Apr 23, 2010 at 11:46 AM, Bill Punch <pu...@cse.msu.edu> wrote:
> To round out the
> top three, which are the ones that get even my best students, look at the
> below:
>
> myVar = 27
>
> def myFun ():
>     print myVar
>     myVar += 1
>     return myVar
>
> print myFun
>
> What happens when you run this?
>

To fully appreciate Bill's example, I think it's worth pointing out
that this version would behave exactly as expected:

myVar = 27

def myFun ():
    print myVar
#    myVar += 1
    return myVar

print myFun()
_______________________________________________
Edu-sig mailing list
Edu-sig@python.org
http://mail.python.org/mailman/listinfo/edu-sig

Reply via email to