<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Team,</div><div><br></div><div>Are we supposed to be able to have our own class dictionary in python 3?</div><div><br></div><div>If we currently cannot -- do we want to be able to?<br></div><div><br></div><div>That we can have out own class dictionary in python 3 is strongly implied in the following at <a href="https://www.python.org/dev/peps/pep-3115/">https://www.python.org/dev/peps/pep-3115/</a> where it says:<br><br>"""</div><div>
<pre class="gmail-literal-block">    # The metaclass invocation
    def __new__(cls, name, bases, classdict):
        # Note that we replace the classdict with a regular
        # dict before passing it to the superclass, so that we
        # don't continue to record member names after the class
        # has been created.
        result = type.__new__(cls, name, bases, dict(classdict))
        result.member_names = classdict.member_names
        return result</pre>

"""</div><div><br></div><div>I don't understand this.  As far as I can tell, no matter what class dictionary you pass into `type.__new__` it creates a copy of it.</div><div><br></div>Am I missing something?  Is this supposed to work?  Is the documentation wrong?</div><div dir="ltr"><br></div><div>Thanks,</div><div><br></div><div>Joy Diamond.</div><div><br></div><div>Program that shows that the class dictionary created is not what we pass in --- Shows the actual symbol table is `dict` not `SymbolTable`<br></div><div><br></div><div>class SymbolTable(dict):<br>    pass<br><br>members = SymbolTable(a = 1)<br><br>X = type('X', ((object,)), members)<br><br>members['b'] = 2<br><br>print('X.a: {}'.format(X.a))<br><br>try:<br>    print('X.b: {}'.format(X.b))<br>except AttributeError as e:<br>    print('X.b: does not exist')<br><br>#<br>#   Get the actual symbol table of `X`, bypassing the mapping proxy.<br>#<br>X__symbol_table = __import__('gc').get_referents(X.__dict__)[0]<br><br>print('The type of the actual symbol table of X is: {} with keys: {}'.format(<br>      type(X__symbol_table),<br>      X__symbol_table.keys()))<br></div><div><br></div><div><br></div><div># Prints out</div><div># X.a: 1<br># X.b: does not exist<br># The type of the actual symbol table of X is: <class 'dict'> with keys: dict_keys(['a', '__module__', '__dict__', '__weakref__', '__doc__'])<br></div></div></div></div><div id="DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br>
<table style="border-top:1px solid #d3d4de">
        <tr>
        <td style="width:55px;padding-top:13px"><a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon" target="_blank"><img src="https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif" alt="" width="46" height="29" style="width: 46px; height: 29px;"></a></td>
                <td style="width:470px;padding-top:12px;color:#41424e;font-size:13px;font-family:Arial,Helvetica,sans-serif;line-height:18px">Virus-free. <a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=link" target="_blank" style="color:#4453ea">www.avast.com</a>
                </td>
        </tr>
</table><a href="#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1"></a></div>