Finding certain values from a dictionary as an input to a constructor python -
so have following code:
# constructor def __init__(self, dict): # inputs harvesting_time = 16 # hours recovery_rate = 90 # % unit_throughput = 93.63 # kg/annum/unit cost_per_unit = 275000 # $ electricity = 0.0000331689825 # kwh/kg/unit energy_cost = 10.41 # cent/kwh labor_cost = 1777000 # $/annum concentration = 100 # g/l throughput = dict.get("output(kg/annum)",default=none) # kg/annum carbon = dict.get("carbon",default=none) nitrogen = dict.get("nitrogen",default=none) carbohydrates = dict.get("carbohydrates",default=none) proteins = dict.get("proteins",default=none) lipids = dict.get("lipids",default=none)
the idea class suppose generate dictionary of values constructor takes input , searches values in order calculations. however, whenever run program (externally), following error.
throughput = dict.get("output(kg/annum)",default=none) # kg/annum
typeerror: get() takes no keyword arguments
could explain error means , how can circumvent it? thank much.
throughput = dict.get("output(kg/annum)",default=none) # kg/annum
don't use keyword "default" when specifying default value.
throughput = dict.get("output(kg/annum)", none) # kg/annum
actually, since default none default, don't have provide second argument @ all.
throughput = dict.get("output(kg/annum)") # kg/annum
Comments
Post a Comment