Skip to content

Commit 514748e

Browse files
author
Philip Guo
committed
imran's got cred
1 parent d823594 commit 514748e

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

‎TODO‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,36 @@ file):
142142
Upgrade to Python 2.7 after moving over to Webfaction, so that I can use
143143
the default standard library "import json"
144144

145+
146+
---
147+
2011-10-05 feedback from Imran:
148+
149+
'''
150+
ok, here's a super artificial example that actually is really confusing
151+
in the standard Python REPL as well:
152+
153+
cA = type("A",(object,),{})
154+
cA2 = type("A",(object,),{})
155+
156+
a=cA()
157+
a2=cA2()
158+
159+
If you visualize this program, it's actually better than CPython because
160+
it shows that the two class objects have different ids even though they
161+
have the same __name__, but then a and a2 are just shown as instances of
162+
"A", which is now ambiguous.
163+
164+
you're well within your rights to call this example bad code (because
165+
holy hell, it is) and out of the scope of your project, but one way to
166+
handle it might be to keep a separate column for type objects, or to
167+
include the class id along with the class __name__ when identifying the
168+
type of an object.
169+
170+
also, if you modify the OOP example to make A and B new-style classes
171+
inheriting from object, the class visualization shows the __dict__ and
172+
__weakref__ fields in the A and B type objects, with no useful repr for
173+
them. Do you really want those shown?
174+
175+
can you tell i've been doing crazy python oop stuff recently?
176+
'''
177+

0 commit comments

Comments
 (0)