This query is further with reference to this query
So, I am trying to execute the following code :
from collections import *
tp = namedtuple('emp', 'eid enames mob')
print(tp)
print(emp)
I can execute print(tp)
and the output generated is <class '__main__.emp'>
.
But when I try to execute print(emp)
, It generates the following exception :
Traceback (most recent call last):
File "a.py", line 5, in <module>
print(emp)
NameError: name 'emp' is not defined
What is the reason. The class emp
is created. But I can not figure out how to access it directly. Or can I not ?
So basically, I can create instance of tp
as tp()
but not instances of emp
in the same way. Why?