On 08/30/2010 05:05 PM, Bradley Hintze wrote:
I may be having a brain fart, but is it at all possible to have a
function first return a value then continue its calculation. Like this
simple example:
my_var = 5
def my_function():
return my_var
my_var +=1
This obviously won't work as
Bradley Hintze wrote:
I may be having a brain fart, but is it at all possible to have a
function first return a value then continue its calculation. Like this
simple example:
my_var = 5
def my_function():
return my_var
my_var +=1
This obviously won't work as written but is
Peter Otten a écrit :
n = 1
def f():
... global n
... try:
... return n
... finally:
... n += 1
...
The same without a global:
def f(_n=[0]):
try:
return _n[0]
finally:
_n[0] += 1
But yeps, using a generator would be better.
--
Bradley Hintze bradle...@aggiemail.usu.edu writes:
my_var = 5
def my_function():
return my_var
my_var +=1
def my_function():
temp = my_var
my_var += 1
return temp
--
http://mail.python.org/mailman/listinfo/python-list
Hi,
On 2010-08-31 02:05, Bradley Hintze wrote:
I may be having a brain fart, but is it at all possible to have a
function first return a value then continue its calculation. Like this
simple example:
my_var = 5
def my_function():
return my_var
my_var +=1
This obviously won't
I may be having a brain fart, but is it at all possible to have a
function first return a value then continue its calculation. Like this
simple example:
my_var = 5
def my_function():
return my_var
my_var +=1
This obviously won't work as written but is there a cleaver way around this.
--
On 31/08/2010 01:05, Bradley Hintze wrote:
I may be having a brain fart, but is it at all possible to have a
function first return a value then continue its calculation. Like this
simple example:
my_var = 5
def my_function():
return my_var
my_var +=1
This obviously won't work as
Bradley Hintze wrote:
I may be having a brain fart, but is it at all possible to have a
function first return a value then continue its calculation. Like this
simple example:
my_var = 5
def my_function():
return my_var
my_var +=1
This obviously won't work as written but is there a
On Mon, Aug 30, 2010 at 5:05 PM, Bradley Hintze
bradle...@aggiemail.usu.edu wrote:
I may be having a brain fart, but is it at all possible to have a
function first return a value then continue its calculation. Like this
simple example:
my_var = 5
def my_function():
return my_var