0

I wold like iterating over recordtype in loop. And also I want to change its values sometimes.

In dict for instance it is very easy

some_dict = {}
for key, value in some_dict.items():
    if not value:
        some_dict[key] = 0

I would like to do same in recordtype. I tried the following cases:

for name in data._fields:
    data[name] = 0
    p = data.__getattribute__(name)
    if not p:
         p = 0
         data.name = 0

or

for name_field, value in data._asdict().iteritems():
    if not value:
        data = data._replace(name_field=0)

And none of them are working..

inspired by this I thought it is easy, but what if I do not exactly know what field in recordtype I must change because it depends on if-statement.

So the question is: how to iterate recordtype and after if-statement change some filed ...?

Thank you in advance!

John
  • 451
  • 6
  • 21

0 Answers0