Select to view content in your preferred language

python error

1000
3
Jump to solution
03-24-2020 10:44 PM
KalSsin
Regular Contributor

Hi~~

def Reclass(arg1, arg2):
    if arg1 in ["222", "333"]:
        return None
    else:
        return arg2

#code
Reclass(!NAME!, !PNAME!)

Please see why there is an error.

0 Kudos
1 Solution

Accepted Solutions
DanPatterson_Retired
MVP Emeritus

#1  You have !PNAME! as one of the parameters and you are trying to calculate the PNAME field..  You can't use the PNAME field to calculate itself

#2  Assuming that you have to calculate values into the PNAME field and you need values from 2 fields, you didn't pass in two arguments to the script in the Pname section the expression line

# 3  AND you need to remove the

#code

Reclass(!Name!, !Pname!)

in the Code block section.  Those lines are not supposed to be included in the code block.

I think you just copied and pasted an example and put some of the wrong things in the wrong place

View solution in original post

3 Replies
DanPatterson_Retired
MVP Emeritus

#1  You have !PNAME! as one of the parameters and you are trying to calculate the PNAME field..  You can't use the PNAME field to calculate itself

#2  Assuming that you have to calculate values into the PNAME field and you need values from 2 fields, you didn't pass in two arguments to the script in the Pname section the expression line

# 3  AND you need to remove the

#code

Reclass(!Name!, !Pname!)

in the Code block section.  Those lines are not supposed to be included in the code block.

I think you just copied and pasted an example and put some of the wrong things in the wrong place

KalSsin
Regular Contributor

I haven't figured out where the right place is yet.
I'll do a little more research.

It's a little difficult.


Thank you for your reply.

0 Kudos
DanPatterson_Retired
MVP Emeritus

Hoping that wasn't you downvoting

0 Kudos