Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

change variable values to None by iterating list...

$
0
0
Hello, I have a script that I run as a tool, so many of the variables come in as "GetParameterAsText". I'm using many of these variables to update rows in a feature class, and I'm having a little bit of an issue with Null values. When a parameter is left blank and I use an update cursor to write that value, it changes the Null value to a blank value. I would like to retain the Null values.

I have found that this works
Code:

if not input:
    input = None

after this process, if I write str(input) to the row, it does just what I want it to (leaves a Null value).

I have a lot of these parameters, so I thought I'd make a list of the variables, and iterate through the list to check if a variable is blank, and then set it to None using the snippet above. However, that doesn't do anything. I found this thread about index pointers, http://www.daniweb.com/software-deve...t-of-variables but that still didn't accomplish what I needed...

Thanks for reading,
Adam

Viewing all articles
Browse latest Browse all 2485

Trending Articles