Antoine Pitrou <pit...@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 <rep...@bugs.python.org>
<https://bugs.python.org/issue35933>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to