0
SCRIPT_BOOL("newList=[]
for x in _arg1:
newList.append(x > 0)
return newList
",SUM([Profit]))

Error processing script IndentationError : expected an indented block (, line 4)

miken32
  • 42,008
  • 16
  • 111
  • 154
  • 3
    Please read an introductory Python tutorial. It will tell you that indentation is **crucial** to Python. The code that you put into your question is clearly not indented, and that makes it invalid. – Stephen C May 06 '17 at 02:45
  • 2
    The other thing to note is that you posted something that is not Python, but Python source embedded in ... something else. I suspect that the real problem is that you are not understanding the interaction between Python (and Python syntactic requirements) and the embedding mechanism. But we can't help you with that without you telling us what your are doing here. – Stephen C May 06 '17 at 02:49
  • 2
    OK ... so this apparently is a product called Tableau. So you should >>tag<< your question appropriately. (And the first [TabPy example](https://www.tableau.com/about/blog/2016/11/leverage-power-python-tableau-tabpy-62077) I came across shows that the embedded Python needs to me properly indented!) – Stephen C May 06 '17 at 02:51

3 Answers3

2

I'm not completely sure what you're asking, but try writing the script like this:

newList=[]
for x in _arg1:
    newList.append(x > 0)
return newList

That has the proper indentation.

SJMcMullan
  • 108
  • 9
1

From a quick read of the TabPy GitHub page, the following code should work but is untested and so provided as is:

SCRIPT_BOOL("newList=[]
for x in _arg1:
    newList.append(x > 0)
return newList",SUM([Profit]))
Talvalin
  • 7,789
  • 2
  • 30
  • 40
0

If you want to have a multiline string, you must use the syntax """I am a multiline string""" instead of "I am not a multiline string".

whackamadoodle3000
  • 6,684
  • 4
  • 27
  • 44