I am not sure I understand what the problem is. Variable doesn't have output, it holds a value (of type integer, string...). So where you write 'subnet', code will behave as if you typed the value stored in 'subnet' variable there.
Your 2nd code example from post #5 looked just fine, namely the "ip=subnet" part. At this point, variable subnet holds the value read from a file, for example "10.1.1.1/24". So when it is executed it behaves same as if you wrote ip='10.1.1.1/24'. Just as with:
x = 5
y = x + 3
y is now 8. In same way subnet is '10.1.1.1/24'
These are so basic programming concepts that frankly make me doubt I understood the real problem. So if I didn't get you right try to explain again, I'll try to help further =)
Your 2nd code example from post #5 looked just fine, namely the "ip=subnet" part. At this point, variable subnet holds the value read from a file, for example "10.1.1.1/24". So when it is executed it behaves same as if you wrote ip='10.1.1.1/24'. Just as with:
x = 5
y = x + 3
y is now 8. In same way subnet is '10.1.1.1/24'
These are so basic programming concepts that frankly make me doubt I understood the real problem. So if I didn't get you right try to explain again, I'll try to help further =)