If you really think this is elegant (a matter of taste, I guess), try:
outputfile.write(value1 + "_NOMINAL" * (type(value1) is str)
+ "_NUMERIC" * (type(value1) in (float, int)))
If you ask me, I think I'd write it like this (assuming the value would only be a string or a number):
print >> outputfile, value1, "NOMINAL" if type(value1) is str else "NUMERIC"
or, if you want to allow for values that are elements of subclasses of str
:
print >> outputfile, value1, "NOMINAL" if isinstance(value1, str) else "NUMERIC"
If there were more things changing, depending on the type of the value, or if there were more than two types, I'd use an if
.