Program - function to showcast documemtation of namedtuple


Topic: Program - function to showcast documemtation of namedtuple

Solution

def show_doc_named():
    from collections import namedtuple
    IplData = namedtuple('IplData', 'match toss choice session1 session2 winner')
    IplData.__doc__ = 'Namedtuple class to store the IPL match data'
    IplData.match.__doc__ = 'Team name'
    IplData.toss.__doc__ = 'Who won the toss'
    IplData.choice.__doc__ = 'Decision taken by wiinng team toss'
    IplData.session1.__doc__ = 'Run scored by Team1'
    IplData.session2.__doc__ = 'Run scored by Team2'
    IplData.winner.__doc__ = 'Winning Team'
    return help(IplData)



List all Python Programs