Simple question about how the optimizer works

Terry Reedy tjreedy at udel.edu
Thu May 9 11:20:20 EDT 2002


"François Pinard" <pinard at iro.umontreal.ca> wrote in message
news:mailman.1020949335.15174.python-list at python.org...

> then `y' should be incremented four times, not one.  Moreover, I do
not
> remember that Python specifies that function arguments are evaluated
left
> to right, or right to left.

Left to right is guaranteed somewhere in ref manual, last I looked.

In response to OP: one of side effects of call to f could be rebinding
of name 'f'.

def f():
  global f
  f = g
  return "First time. "

def g():
  return "Ha, ha! Fooled you?"

print f(), f()
#prints
First time.  Ha, ha! Fooled you?

Terry J. Reedy







More information about the Python-list mailing list