Python Forum
How to print the content of the object?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to print the content of the object?
#1
I have a python file in which I have written the following data

@dataclass
class Email:
    resource_uri : str
    address      : str
    person       : str
    time         : str
    origin       : str
    primary      : bool
    active       : bool

class DataTracker:
    """
    A class for interacting with the IETF DataTracker.
    """
    def __init__(self):
        self.session      = requests.Session()
        self.base_url     = "https://datatracker.ietf.org"


    def __del__(self):
        self.session.close()

    def email(self, email: str):
        """
        Lookup information about an email address in the datatracker.

        Parameters:
           email : the email address to lookup

        Returns:
            An Email object
        """
        response = self.session.get(self.base_url + "/api/v1/person/email/" + email + "/", verify=True)
        if response.status_code == 200:
            return Pavlova().from_mapping(response.json(), Email)
        else:
            return None
How do I print the details of an object of email type and a particular attribute say "address" of the email??

I have written the code snippet but I am not sure how to print the result as it brought upon errors

import datatracker

##Creating an object of Datatracker type

datatracker_object=datatracker.DataTracker()

## calling the email function and storing in object
email_object=datatracker_object.email('https://datatracker.ietf.org/api/v1/person/email/[email protected]/')

print(email_object['address'])
Kindly help.Thanks
Reply


Messages In This Thread
How to print the content of the object? - by janaki26794 - Jul-21-2019, 01:37 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  print all method and property of list object engmoh 4 2,898 Oct-26-2019, 05:33 PM
Last Post: engmoh

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020