Thanks hgvyas123,
Your solution of adding the brackets:
print (doit.foo())
solves the problem.
At first I couldn’t understand why but then I found in PiL:
“If the function has one single argument and this argument is either a literal string or a table constructor , then the parentheses are optional”
So while it’s ok to write:
print “Hello World” instead of print(“Hello World”)
and
print {“hello”, “world”} instead of print ({“hello”, “world”})
it’s not ok to write:
print 5
or
print foo()
or
print doit.foo()
the brackets are needed in these situations.
Maybe the way to remember this, is that you can only drop the brackets when there’s a matching pair of characters surrounding the argument.
In the case of print “Hello World” this is " and "
In the case of print {“hello”, “world”} this is { and }
And print foo() doesn’t have this matching pair so we need:
print (foo())
[import]uid: 67842 topic_id: 13059 reply_id: 48038[/import]