0

I am trying to pass the {query} parameter to my python script (python newbie) so I can create a really simply calculation.

Heres what the workflow looks like:
enter image description here

My python script looks like this:

query="{query}"

x = float(query)/60

y = x*100

print "%.2f" % x, "%.2f" % y

However when I run it my debug returns this error:

[2018-10-13 21:56:25][ERROR: action.script]
Traceback (most recent call last):
  File "/Users/Imran/Library/Caches/com.runningwithcrayons.Alfred-3/Workflow Scripts/A4A451B6-E747-4D1C-A957-431E755787A5", line 3, in <module>
    x = float(query)/60
ValueError: could not convert string to float: {query}

How can I resolve this? I want to be able to run bill 30 to return a percentage calculation for me.

deadvoid
  • 1,270
  • 10
  • 19
InvalidSyntax
  • 9,131
  • 20
  • 80
  • 127

1 Answers1

0

In addition to the language you have two options in your Run Script object: with input as argv and with input as {query}.

If you have the first option selected your code should be this:

import sys

query = sys.argv[1]

x = float(query)/60

y = x*100

print "%.2f" % x, "%.2f" % y

In the second case your code should be this:

import sys

query = "{query}"

x = float(query)/60

y = x*100

print "%.2f" % x, "%.2f" % y
xilopaint
  • 699
  • 1
  • 7
  • 16