I have a file with several variables that looks like this:
BTC = 375.23
SOL = 200.42
LTC = 208.91
DOT = 60.12
And a main script. How can I append those values ? Example: change BTC = 375.23
to BTC = 420.32
. The methods I'm using are:
from varfile import * # imported this way for trial and error
from varfile import BTC # imported this way for trial and error
import varfile
def blah():
varfile.BTC.append(float(420.32))
blah()
But I'm getting an error: AttributeError: 'float' object has no attribute 'append'
I feel like I just need to convert the float
to str
somehow but not having luck.
I've found a couple similar posts but nothing quite the same and nothing that works the way I'd like.
Let me clarify a little and maybe add some context.
There is 2 files, one is my main script and the other file contains data - the variables I mentioned that are in varfile.py
. The data file doesn't need to be any specific type of file, it can be a txt
file or json
, anything.
When the main script is ran, I want it to read the values to the variables BTC
, SOL
and so on. After those values are read and used in the function, I want to change those values for next time I run the main script.