2

I am using Azure Confidential Ledger, and I am trying to query it. But when I want to print a variable that contain value I encounter following line as an output:

bound method ConfidentialLedgerClientOperationsMixin.list_ledger_entries of <azure.confidentialledger._patch.ConfidentialLedgerClient object at 0x000001BAD31ED048>>

My code is as follow:

from azure.confidentialledger import ConfidentialLedgerClient
from azure.confidentialledger.certificate import ConfidentialLedgerCertificateClient
from azure.identity import DefaultAzureCredential

identity_client = ConfidentialLedgerCertificateClient()
network_identity = identity_client.get_ledger_identity(
    ledger_id="MyLedger"
)

ledger_tls_cert_file_name = "ledger_certificate.pem"
with open(ledger_tls_cert_file_name, "w") as cert_file:
    cert_file.write(network_identity["ledgerTlsCertificate"])

credential = DefaultAzureCredential()
ledger_client = ConfidentialLedgerClient(
    endpoint="https://MyLedger.confidential-ledger.azure.com",
    credential=credential,
    ledger_certificate_path=ledger_tls_cert_file_name
)

d = ledger_client.list_ledger_entries

print(d)

In addition, I have read following questions:

  1. How to print the value of the object?
  2. Is there a built-in function to print all the current properties and values of an object?
OmT
  • 59
  • 4
  • 1
    Did you mean to **call** `list_ledger_entries`? – Davis Herring Oct 22 '22 at 23:06
  • Thanks, I'm not sure...I wanted to query the ledger to see what is on it; thus, I thought maybe by printing "ledger_client.list_ledger_entries" I can achieve that! – OmT Oct 22 '22 at 23:09

1 Answers1

1

Try this:

d = ledger_client.list_ledger_entries()

instead of this

d = ledger_client.list_ledger_entries

in your code, you did not assign the the result of the method call to the var d but instead assigned the method list_ledger_entries's object of ledger_client to d

  • Thanks a lot for elaborating...now there is a new issue, by using "d = ledger_client.list_ledger_entries()"...the output is: – OmT Oct 22 '22 at 23:12
  • 1
    ok that great step into solving the prob! – Fares_Hassen Oct 22 '22 at 23:20
  • 1
    now since its like that, that means the value doesnt have a __repr__ or __str__ magic method to it – Fares_Hassen Oct 22 '22 at 23:21
  • 1
    try d = [ele for ele in edger_client.list_ledger_entries()] – Fares_Hassen Oct 22 '22 at 23:22
  • Thanks, error: File "C:\Users\Administrator\.venv\lib\site-packages\azure\core\paging.py", line 128, in __next__ return next(self._page_iterator) File "C:\Users\Administrator\.venv\lib\site-packages\azure\core\paging.py", line 76, in __next__ self._response = self._get_next(self.continuation_token) – OmT Oct 23 '22 at 00:10