Bottom Page

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
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  class returns NoneType Object istemihan 0 121 Aug-12-2019, 11:47 AM
Last Post: istemihan
  Object and type class Uchikago 2 177 Jul-28-2019, 10:35 AM
Last Post: DeaD_EyE
  Return a value when I equal an object from a class ihouses 4 253 Jul-10-2019, 02:44 AM
Last Post: SheeppOSU
  How to save a class object to a file? SheeppOSU 2 229 Jun-22-2019, 11:54 PM
Last Post: metulburr
  call dict object result key error lateublegende 2 330 May-15-2019, 01:08 PM
Last Post: lateublegende
  saving (in text or binary) an object under a defined class cai0824 3 384 May-12-2019, 08:55 AM
Last Post: snippsat
  Why Can't I call base class function for my derived class object? AmirAB 2 355 Feb-13-2019, 03:04 PM
Last Post: snippsat
  Class Object hellp Dneal620 1 313 Dec-18-2018, 12:19 AM
Last Post: micseydel
  Class object instance. Link instance attribute to class. Can it be done easier. Windspar 7 633 Dec-03-2018, 11:16 PM
Last Post: Windspar
  general conversion to int Skaperen 3 543 Aug-09-2018, 12:23 AM
Last Post: Skaperen

Forum Jump:


Users browsing this thread: 1 Guest(s)