namedtuple: A Lightweight Python Structure to Mange your Data

namedtuple: A Lightweight Python Structure to Mange your Data

If you need a small class to manage data in your project, consider using namedtuple.

namedtuple object is like a tuple but can be used as a normal Python class.

In the code above, I use namedtuple to create a Person object with attributes name and gender. Just like Python class,  you can access attributes of namedtuple using obj.attr.

Search

Related Posts

Related Posts

Scroll to Top

Work with Khuyen Tran

Work with Khuyen Tran