Closed gioxc88 closed 1 year ago
I think this is intended. A function definition is not considered a proper expression.
py2vega supports simple if
conditions for convenience even though it's not a proper expression too.
honestly without partial function this thing is very difficult to use. Like you can use it in very simple cases but not really useful. For example I can't possibly write a function for every format specifier and hadrcode the specifier in it. It's not practical. I don't think it would be difficult to remove extra indent and the beginning when parsing the function
py2vega
turns Python expressions into vega expressions. A function definition is not an expression. Python also does not support doing this:
eval('''
def foo():
pass
''')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 2
def foo():
^^^
SyntaxError: invalid syntax
As I said, py2vega supports if
conditions for convenience, same for simple variable assignment. But this is already quite hacky to allow this. Allowing function definition will be really painful to implement and maintain, it's also not the purpose of this library.
Closing as wont fix
a simple function like this would not work as it returns indentation error