[Tutor] Persistent values in functions
Pijus Virketis
virketis@fas.harvard.edu
Wed, 22 May 2002 02:08:03 -0400
<HTML><HEAD>
<BASEFONT FACE=3D"Arial" SIZE=3D"2" COLOR=3D"#000000">
</HEAD>
<BODY>
<div>Seiji,</div>
<div> </div>
<div>>I'd like to know if Python supports persistent=
values</div>
<div>>in functions: a variable type that saves its=
value</div>
<div>>when the function returns, and gives the value=
when</div>
<div>>the function is called again. I seem to recall=
that</div>
<div>>you can do this in C. Please provide syntax=
and</div>
<div>>perhaps a simple example.</div>
<div> </div>
<div>I think you want the generator functions, available in=
Python 2.2. Check out this article's second half for=
introduction and code samples: <a=
href=3D"http://www-106.ibm.com/developerworks/linux/library/l">htt=
p://www-106.ibm.com/developerworks/linux/library/l</a>-</div>
<div>pycon.html?dwzone=3Dlinux.</div>
<div> </div>
<div>Cheers,</div>
<div> </div>
<div>Pijus</div>
<div> </div>
<div> </div>
<div>-- </div>
<div>"Those who can make you believe absurdities</div>
<div>can make you commit atrocities" - Voltaire</div>
</body></html>