osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

what is payload


Era el Thu, 7 Sep 2017 00:48:34 -0700 (PDT) en comp.lang.python,
cuando de repente Andrej Viktorovich
dijo lo siguiente acerca de
what is payload:

>  Hello,
> 
>  Have working sample with strange property - payload:
> 
>  class ExampleClass(object):
>      def __init__(self,value):
>          print("Initialising instance...")
>          self.payload = value
> 
>  exampleInstance = ExampleClass(42)
>  print(exampleInstance.payload)
> 
> 
>  Is it some default field that all objects has? What it is used for?
> 
>   

No, it's just that Python lets you add members to your instance at
runtime. In this case, that code is adding an instance variable called
payload, but it's not some special property or anything.