[docs] [issue35933] python doc does not say that the state kwarg in Pickler.save_reduce can be a tuple (and not only a dict)

Antoine Pitrou report at bugs.python.org
Thu Feb 7 17:21:37 EST 2019


Antoine Pitrou <pitrou at free.fr> added the comment:

You can have both a dict and slots by subclassing:

>>> class A: 
...:     __slots__ = ('x',) 
...:                                                                                                                                                                   
>>> class B(A): pass                                                                                                                                                   
>>>                                                                                                                                                                    
>>> b = B()                                                                                                                                                            
>>> b.x = 5                                                                                                                                                            
>>> b.y = 6                                                                                                                                                            
>>> b.__dict__                                                                                                                                                         
{'y': 6}
>>> A.x                                                                                                                                                                
<member 'x' of 'A' objects>
>>> A.x.__get__(b)                                                                                                                                                     
5

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35933>
_______________________________________


More information about the docs mailing list