[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>&nbsp;</div>
<div>&gt;I'd like to know if Python supports persistent=
 values</div>
<div>&gt;in functions:&nbsp; a variable type that saves its=
 value</div>
<div>&gt;when the function returns, and gives the value=
 when</div>
<div>&gt;the function is called again.&nbsp; I seem to recall=
 that</div>
<div>&gt;you can do this in C.&nbsp; Please provide syntax=
 and</div>
<div>&gt;perhaps a simple example.</div>
<div>&nbsp;</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>&nbsp;</div>
<div>&nbsp;</div>
<div>-- </div>
<div>&quot;Those who can make you believe absurdities</div>
<div>can make you commit atrocities&quot; - Voltaire</div>
</body></html>