name = 'Guido'
class MyClass:
name = 'Raymond'
list_1 = [name] * 3
list_2 = [name for i in range(3)]
@classmethod
def hello(cls):
return '{} says hello'.format(name)
If i do this? it prints the following:
>>> print(MyClass.hello())
Guido says hello
>>> print(MyClass.list_1)
['Raymond', 'Raymond', 'Raymond']
>>> print(MyClass.list_2)
['Guido', 'Guido', 'Guido']
My question here is,
- Why don't it prints 'Raymond' instead of 'Guido' on 3rd Output.
- How to make it print as:
Raymond says hello