[Tutor] functions
Kalle Svensson
kalle@lysator.liu.se
Sun Dec 1 09:20:02 2002
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
[me]
> If you added the line
>
> print d
>
> to the function in example two, it would lookup d and find a binding
> in the local namespace. It would then print this object, the string
> 'goodbye'.
Exercise for the interested reader: What will this code print? Why?
>>> d = 'foo'
>>> def func():
... print d
... d = 'bar'
... print d
...
>>> func()
Peace,
Kalle
- --
Kalle Svensson, http://www.juckapan.org/~kalle/
Student, root and saint in the Church of Emacs.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.6 <http://mailcrypt.sourceforge.net/>
iD8DBQE96hpKdNeA1787sd0RAl4uAJ43ZZNXH/mi1d+sQLfU0yaobUcnqQCfT7Ab
4/naJ3YiiWS26T6+SnH6a3c=
=cUZY
-----END PGP SIGNATURE-----