Paul Moore wrote:
I'm translating some code from another language (Lua) which has
multiple function return values. So, In Lua, it's possible to define a
function
function f()
return 1,2,3
end
which returns 3 values. These can then be used/assigned by the caller:
a,b,c = f()
So far, much like Python, but the key difference is that in Lua,
excess arguments are ignored - so you can do
py> class mytuple(tuple):
def magic(self, astr):
names = astr.split()
for name, val in zip(names, self):
globals()[name] = val
...
py> t = mytuple((1,2,3))
py> t.magic('a b')
py> a
1
py> b
2
James
--
http://mail.python.org/mailman/listinfo/python-list