Trouble using tables in settings case

Viewed 21

I tried to make some settings table and read from it, but I don't really know how. I need it to be something like that.

in lua its like that as below, i need that on python

settings = {amount = 100}
print(settings.amount)
1 Answers

I don't know Lua, but it seems to me that, in Python terms, you want to define a class that has an attribute named amount, and you want an instance of that class named settings whose amount is 100.

If so, then the Python way of doing that would be:

class My_class():

    def __init__(self, amount):
        self.amount = amount

settings = My_class(100)

You can verify that with print(settings.amount), which gives an output of 100.

Related