Select to view content in your preferred language

FindLabel not Definied

2439
3
10-25-2012 02:35 PM
MikeMacRae
Frequent Contributor
I'm trying to make an advanced label expression using the python parser and I keep getting the following error:

[ATTACH=CONFIG]18753[/ATTACH]

def FindLabel ( [Direction] ):
  return  "{}° {}' {}\"".format( [Direction].split("-"))


Can anyone tell me why FindLabel is not defined?
Tags (2)
0 Kudos
3 Replies
MarcinGasior
Frequent Contributor
I suppose that you can't use list (result of split()) as a format() argument in this way.
The format() function accepts single strings as arguments, eg. .format("50", "50", "50")

To use specific element from a list try this code:
def FindLabel ( [Direction] ):
  return  "{0[0]}° {0[1]}' {0[2]}\"".format( [Direction].split("-"))
0 Kudos
MikeMacRae
Frequent Contributor
Hey Marcin,

I tried this approach and I am still getting the same error. Not sure why it says FindLabel is not defined when it's defined in the function right off the bat.
0 Kudos
MathewCoyle
Honored Contributor
I think the issue is it doesn't like returning the field value.

Try this.
def FindLabel ( [Direction] ):
  var = [Direction]
  return  "{}° {}' {}\"".format(var.split("-"))
0 Kudos