Answer the question
In order to leave comments, you need to log in
How can I put all parameters into an object while iterating over an array?
I want to shove several parameters into an object that are in an array
class obj(object):
def __init__(
self,
text='white',
background='white'
):
print('{}-{}'.format(
text,
background
))
# Дальше идет куча другого кода...
def fun(**kwargs) :
for x in range(2) :
for key, value in kwargs.items():
#obj(**kwargs)
if key == 'text' :
obj(key=value[x+1])
else:
obj(key=value[x])
fun(
text=[
'red',
'blue',
'green'
],
background=[
'black',
'yellow',
'brown'
]
)
fun()
1
blue-black
green-yellow
2
white-black
white-black
Answer the question
In order to leave comments, you need to log in
Can you explain your task properly? There are no arrays in the code at all, only linear lists.
put multiple parameters into an objectwhat???? And at least observe pep8 a little, please.
obj is an object. It's not an instance of an object, so there's no way you can do it
See OOP Principles
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question