**kwargs: Why is the below list comprehension not printing outputs while normal for loop does?
04:21 08 Oct 2018

In Python 3 I am trying to print the outputs of a **kwargs using a list comprehension. I am unable to do so while using a for loop does print the elements of my list input. Below is the reproducible code:

Using list comprehension:

class Practice(object):
    __acceptable_keys_list = ['Right', 'left']

    def __init__(self, **kwargs):
        temp = ([self.__setattr__(key, kwargs.get(key)) for key in self.__acceptable_keys_list])
        print(temp)

Output is [None, None].

Where as using a for loop:

class Practice(object):
    __acceptable_keys_list = ['Right', 'Left']
    
    def __init__(self, **kwargs):   
         for key in self.__acceptable_keys_list:
             self.__setattr__(key,kwargs.get(key))
             print(key)

Output is [Right, Left].

Why the difference ? What am I missing ? Shouldn't list comp and for loops behave in similar manner?

python python-3.x