Python Forum
General query regarding conversion of dict to class object
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
General query regarding conversion of dict to class object
#1
i have a object of type class<'postdata'>
This object contains details of a person
Now to convert this object to string.I have tried
json.dumps(object)
But this gives error like
object of type "postdata" is not json serializable
So i have tried
json.loads(json.dumps(object,default=lambda x: x.__dict__))
The output to above statement is dictionary
How to display this in initial format on console.I want type of output to be again
class<'postdata'>
Second question is
i have function
def abc():
   print("call in function abc")
so instead of writing "call in function abc",the function name should be taken dynamically,like what ever is function name ,it should print like calling that function,without us specifying abc
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  error in class: TypeError: 'str' object is not callable akbarza 2 444 Dec-30-2023, 04:35 PM
Last Post: deanhystad
  dict class override: how access parent values? Andrey 1 1,594 Mar-06-2022, 10:49 PM
Last Post: deanhystad
Exclamation win32com: How to pass a reference object into a COM server class Alfalfa 3 4,799 Jul-26-2021, 06:25 PM
Last Post: Alfalfa
  AttributeError class object has no attribute list object scttfnch 5 3,339 Feb-24-2021, 10:03 PM
Last Post: scttfnch
  Python Class and Object Parameters JoeDainton123 5 2,827 Sep-02-2020, 10:43 AM
Last Post: JoeDainton123
  Multiprocessing, class, run and a Queue Object SeanInColo 0 1,491 Jul-12-2020, 05:36 PM
Last Post: SeanInColo
  Sort a dict in dict cherry_cherry 4 62,283 Apr-08-2020, 12:25 PM
Last Post: perfringo
  Hi, need help with class, object Houston222 1 1,804 Apr-04-2020, 01:55 PM
Last Post: buran
  Object reference in Dict - not resolved at runtime benthomson 2 1,794 Apr-02-2020, 08:50 AM
Last Post: benthomson
  class returns NoneType Object istemihan 0 2,213 Aug-12-2019, 11:47 AM
Last Post: istemihan

Forum Jump:

User Panel Messages

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